Skip to content

Fix: dag next-execution --table crashes when no next run exists (#67394)#67425

Draft
bramhanandlingala wants to merge 3 commits into
apache:mainfrom
bramhanandlingala:fix/dag-next-execution-table-none-crash
Draft

Fix: dag next-execution --table crashes when no next run exists (#67394)#67425
bramhanandlingala wants to merge 3 commits into
apache:mainfrom
bramhanandlingala:fix/dag-next-execution-table-none-crash

Conversation

@bramhanandlingala

@bramhanandlingala bramhanandlingala commented May 24, 2026

Copy link
Copy Markdown
Contributor

When you run airflow dags next-execution <dag_id> --table, it crashes with an AttributeError if the DAG has no upcoming scheduled run.
For example when
schedule=None, or when a @once DAG has already run and you ask for a second execution with --num-executions 2.

The bug is in the --table branch of dag_next_execution. It used a one-liner list comprehension that called operator.attrgetter on every item yielded by iter_next_dagrun_info(). The problem is that iterator can yield None to signal "no more runs", and calling an attribute getter on None blows up immediately.

The non-table code path right below it already handles this correctly. it checks if info is None, prints a warning to stderr, and carries on. The table branch just never got the same treatment.

This PR fixes it by expanding the list comprehension into a proper loop, adding the same None check, and emitting the same warning message.
Valid runs are collected into a list and printed as a table as before; None entries are skipped with a warning.

Are you willing to submit PR?
Yes, if helpful.

Code of Conduct

I agree to follow this project's Code of Conduct

closes: #67394


Important

🛠️ Maintainer triage note for @bramhanandlingala · by @potiuk · 2026-07-18 16:36 UTC

I've removed the ready for maintainer review label — the next step here is yours:

  • Merge conflicts with main. See docs.

It'll return to the maintainer queue automatically once resolved — no need to re-add the label by hand. See the Pull Request quality criteria for details.

The ball is in your court — you've been assigned. Rebase onto main, push, then mark it Ready for review.

Automated triage — may be imperfect; a maintainer takes the next look.

…he#67394)

The table branch of dag_next_execution applied operator.attrgetter directly
on values from iter_next_dagrun_info() without guarding against None.
This caused an AttributeError when a DAG has schedule=None or @once
exhausts its single run. Mirror the non-table path existing None-guard:
skip None values, emit the same stderr warning, and print an empty table.

Adds parametrised tests for schedule=None, @once with 1 and 2 executions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@boring-cyborg

boring-cyborg Bot commented May 24, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@vamsivasireddy-ops vamsivasireddy-ops left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great way to handle!

@bramhanandlingala

Copy link
Copy Markdown
Contributor Author

@ashb @XD-DENG @bolkedebruin @jedcunningham @ephraimbuddy
Could you please review this PR? It touches DAG-related code.

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label May 28, 2026
@potiuk

potiuk commented Jun 25, 2026

Copy link
Copy Markdown
Member

@bramhanandlingala — I've removed the ready for maintainer review label because the next step here is yours: this branch now has merge conflicts with main. It'll go back into the maintainer queue automatically once you rebase onto the latest main and push — no need to re-add the label by hand. There's no rush.

Automated triage note drafted by an AI-assisted tool — may get things wrong; a real Apache Airflow maintainer takes the next look once it's green. (why automated)


Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting

@potiuk potiuk removed the ready for maintainer review Set after triaging when all criteria pass. label Jun 25, 2026
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 2, 2026
@potiuk potiuk removed the ready for maintainer review Set after triaging when all criteria pass. label Jul 18, 2026
@potiuk
potiuk marked this pull request as draft July 20, 2026 11:54
@potiuk

potiuk commented Jul 20, 2026

Copy link
Copy Markdown
Member

@bramhanandlingala This PR has been converted to draft because it does not yet meet our Pull Request quality criteria.

Issues found:

  • Merge conflicts: This PR has merge conflicts with main and cannot be merged as-is. Rebase locally and resolve them: git fetch upstream main && git rebase upstream/main, resolve the conflicts, then force-push.

Note: Your branch is 1281 commits behind main. Some check failures may be caused by changes in the base branch rather than by your PR. Please rebase your branch and push again to get up-to-date CI results.

What to do next:

  • Fix each issue listed above.
  • Make sure static checks pass locally (prek run --from-ref main --stage pre-commit).
  • Mark the PR as "Ready for review" when you're done.

Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the Airflow Slack.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

airflow dags next-execution --table crashes when no next run exists

4 participants