Skip to content

Fix airflowctl commands crashing instead of printing their result - #72675

Merged
henry3260 merged 1 commit into
apache:mainfrom
Eason09053360:fix-airflowctl-missing-output-flag
Sep 30, 2026
Merged

henry3260 merged 1 commit into
apache:mainfrom
Eason09053360:fix-airflowctl-missing-output-flag

Conversation

@Eason09053360

Copy link
Copy Markdown
Contributor

Five auto-generated airflowctl commands crashed with a raw traceback instead of printing their result:

$ airflowctl connections test --connection-id my_conn --conn-type http
Traceback (most recent call last):
  ...
  File "airflowctl/ctl/cli_config.py", line 926, in _get_func
    output=args.output,
           ^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'output'

CommandFactory generates every airflowctl command from the operations layer, and each generated
command finishes by printing through args.output. But --output was only declared for commands
whose method name started with one of ten CRUD verbs (list, get, create, …). The commands whose
verb was not on that list never got the flag declared, so argparse never put output on the
namespace, and they died in the printer — after their HTTP request had already been sent and
applied server-side, so the user sees a crash for an operation that actually succeeded.

Affected commands:

Command Operation
airflowctl assets materialize AssetsOperations.materialize
airflowctl backfill pause BackfillOperations.pause
airflowctl backfill unpause BackfillOperations.unpause
airflowctl backfill cancel BackfillOperations.cancel
airflowctl connections test ConnectionsOperations.test

Rather than adding the five missing verbs to the list, this drops the condition for --output
entirely: there is no generated command that does not print, so the distinction the whitelist tried
to draw does not exist. Guessing by verb prefix is also wrong in both directions — an operation named
settings would have matched set by accident.

-e/--env deliberately keeps the existing whitelist rather than riding along. Nothing reads
args.env for generated commands (only auth login / auth token do), so widening it would replace
today's honest unrecognized argument error with silent acceptance of an environment the command
then ignores — running against production credentials while the user believes they targeted staging.
Making --env actually work is tracked in #70519.

Tests

  • test_every_generated_command_accepts_the_output_flag — asserts no generated command is missing
    --output. Without the fix it fails listing exactly the five commands above. This is the guard
    that stops the whitelist coming back.
  • test_connections_test_reaches_the_printer — drives connections test through the real
    cli_parser.get_parser() end to end. Without the fix it raises the AttributeError above.

Both were confirmed to fail with the source change reverted. Full airflow-ctl suite: 389 passed.

Note for reviewers

generate-airflowctl-help-images was skipped locally (it needs Docker). Its hashes already drift on
an unmodified main — I verified the identical eight groups differ with and without this change — so
regenerating the SVGs here would only pull unrelated churn into this PR. Happy to add a commit if CI
disagrees.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

airflowctl generates its commands from the operations layer, and every
generated command finishes by printing through ``args.output``. That flag
was only declared for commands whose method name happened to start with
one of ten CRUD verbs, so the ones that did not — ``assets materialize``,
``backfill pause|unpause|cancel`` and ``connections test`` — reached the
printer with the attribute undefined and died with a raw traceback, after
their request had already been sent and applied server-side.

``-e/--env`` deliberately keeps its existing whitelist. Nothing reads
``args.env`` for generated commands, so widening it would only let more
commands silently accept an environment they then ignore and run against
production credentials instead; that is tracked separately in
apache#70519.
@potiuk

potiuk commented Sep 25, 2026

Copy link
Copy Markdown
Member

Hello @Eason09053360 - thank you for your contributions to Apache Airflow!

The Airflow community has introduced a limit of 5 open pull requests at a time for contributors without write access to the repository. You currently have 33 open pull requests, so - as a one-time step of introducing the limit - we closed the ones where maintainers have not engaged yet:

These pull requests stay open because maintainers are already engaged in them - they count towards your limit:

This is not a judgement of you or of your changes. We never told contributors before that opening many pull requests at once was a problem, so there is nothing to feel bad about - and nothing is lost: your branches, commits and the review history stay where they are.

What we ask you to do is to make your first prioritization decision: choose which of the pull requests above matter most to you, and reopen them (up to 5 open at a time, including the ones still open) with the "Reopen pull request" button or gh pr reopen <PR_NUMBER> --repo apache/airflow. Reopen the ones you are ready to follow through - keep them rebased, respond to review comments and fix failing checks.

While your pull requests are waiting for review, the most valuable thing you can do is help in other ways - reviewing other contributors' pull requests, helping with issues, and taking part in the discussions on the devlist and Slack.

Why we introduced the limit, what it means for you and how to reopen or restore a pull request is explained in https://github.com/apache/airflow/blob/main/contributing-docs/32_open_pull_request_limit.rst.


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

@henry3260 henry3260 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@henry3260
henry3260 merged commit f31b572 into apache:main Sep 30, 2026
261 of 262 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport failed to create: airflow-ctl/v0-1-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
❌ airflow-ctl/v0-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker f31b572 airflow-ctl/v0-1-test

This should apply the commit to the airflow-ctl/v0-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

henry3260 added a commit that referenced this pull request Oct 1, 2026
…2675) (#73988)

airflowctl generates its commands from the operations layer, and every
generated command finishes by printing through ``args.output``. That flag
was only declared for commands whose method name happened to start with
one of ten CRUD verbs, so the ones that did not — ``assets materialize``,
``backfill pause|unpause|cancel`` and ``connections test`` — reached the
printer with the attribute undefined and died with a raw traceback, after
their request had already been sent and applied server-side.

``-e/--env`` deliberately keeps its existing whitelist. Nothing reads
``args.env`` for generated commands, so widening it would only let more
commands silently accept an environment they then ignore and run against
production credentials instead; that is tracked separately in
#70519.

Co-authored-by: Eason09053360 <[email protected]>
(cherry picked from commit f31b572)

The pick is not clean, because this branch does not carry the commit that
introduced ``_call_generated_command`` and the ``test_primitive_param_*``
tests. Git offered those alongside this change in the conflict; they are
left out, since they belong to that commit rather than this one, as do the
``ClearTaskInstancesBody`` and ``DagRunOperations`` imports they need.
``from unittest import mock`` is plain context on main and is added here
for the same reason: the test this commit adds needs it, and the commit
that would have brought it is not on this branch.

Co-authored-by: Y-C <[email protected]>
shahar1 pushed a commit that referenced this pull request Nov 19, 2026
…2675) (#73988)

airflowctl generates its commands from the operations layer, and every
generated command finishes by printing through ``args.output``. That flag
was only declared for commands whose method name happened to start with
one of ten CRUD verbs, so the ones that did not — ``assets materialize``,
``backfill pause|unpause|cancel`` and ``connections test`` — reached the
printer with the attribute undefined and died with a raw traceback, after
their request had already been sent and applied server-side.

``-e/--env`` deliberately keeps its existing whitelist. Nothing reads
``args.env`` for generated commands, so widening it would only let more
commands silently accept an environment they then ignore and run against
production credentials instead; that is tracked separately in
#70519.

Co-authored-by: Eason09053360 <[email protected]>
(cherry picked from commit f31b572)

The pick is not clean, because this branch does not carry the commit that
introduced ``_call_generated_command`` and the ``test_primitive_param_*``
tests. Git offered those alongside this change in the conflict; they are
left out, since they belong to that commit rather than this one, as do the
``ClearTaskInstancesBody`` and ``DagRunOperations`` imports they need.
``from unittest import mock`` is plain context on main and is added here
for the same reason: the test this commit adds needs it, and the commit
that would have brought it is not on this branch.

Co-authored-by: Y-C <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:airflow-ctl backport-to-airflow-ctl/v0-1-test closed because of open PR limit Closed as a one-time step of introducing the open pull request limit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants