Eason09053360 opened a new pull request, #72675:
URL: https://github.com/apache/airflow/pull/72675

   Five auto-generated `airflowctl` commands crashed with a raw traceback 
instead of printing their result:
   
   ```console
   $ 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?
   
   - [X] Yes — Claude Code (Opus 5)
   
   Generated-by: Claude Code (Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
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