vincere-mori opened a new pull request, #67417:
URL: https://github.com/apache/airflow/pull/67417

   ## Summary
   
   `airflow dags next-execution <dag_id> --table` crashes with `AttributeError` 
when the DAG has no next scheduled run (e.g. `schedule=None`, or an `@once` DAG 
after its run, or `--num-executions` exceeds available runs).
   
   The root cause is in the table-output branch:
   
   ```python
   # Before (buggy)
   AirflowConsole().print_as_table([{n: f(o) for n, f in getters} for o in 
iter_next_dagrun_info()])
   ```
   
   `iter_next_dagrun_info()` yields `DagRunInfo | None`. When `o` is `None`, 
calling `operator.attrgetter(c)(None)` raises `AttributeError: 'NoneType' 
object has no attribute 'logical_date'`.
   
   The non-table path already handles `None` correctly:
   
   ```python
   for info in iter_next_dagrun_info():
       if info is None:
           print("[WARN] No following schedule can be found. ...", 
file=sys.stderr)
           ...
   ```
   
   ## Reproduce
   
   ```python
   # no_schedule_dag.py
   from airflow import DAG
   from pendulum import datetime
   
   with DAG("no_schedule", start_date=datetime(2025, 1, 1, tz="UTC"), 
schedule=None):
       pass
   ```
   
   ```bash
   airflow dags next-execution no_schedule --table
   # AttributeError: 'NoneType' object has no attribute 'logical_date'
   ```
   
   ## Fix
   
   Mirror the non-table `None` guard in the table path: skip `None` items and 
print the same warning to stderr.
   
   Fixes #67394


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to