Skip to content

Make required params positional for auto-generated airflowctl commands#64812

Open
shivaam wants to merge 2 commits intoapache:mainfrom
shivaam:fix/positional-params-airflowctl-60142
Open

Make required params positional for auto-generated airflowctl commands#64812
shivaam wants to merge 2 commits intoapache:mainfrom
shivaam:fix/positional-params-airflowctl-60142

Conversation

@shivaam
Copy link
Copy Markdown
Contributor

@shivaam shivaam commented Apr 6, 2026

Required non-boolean parameters in auto-generated CLI commands are now positional instead of flag-style, improving UX consistency with manually defined commands like dags pause.

Before:

airflowctl connections create --connection-id="test" --conn-type="mysql" --password=secret
airflowctl dags get --dag-id=example_bash_operator

After:

airflowctl connections create test mysql --password=secret
airflowctl dags get example_bash_operator

Changes

  • Track which operation parameters have default values during AST parsing
  • For primitive params, use the default info to decide positional vs flag
  • For Pydantic model fields, use is_required() to decide positional vs flag
  • Use _UNSET for arg_dest default to avoid argparse crash on positional args
  • Skip the has_default metadata key at runtime when mapping CLI args to method params
  • Updated unit tests and integration test commands to match new positional syntax
  • Added 2 new tests for positional arg behavior and default detection
  • Added newsfragment for the breaking change

Notes

  • _create_arg stays a dumb pass-through builder — all positional/flag logic is in the callers via one-liner conditionals
  • Booleans are never positional (they need --flag/--no-flag)
  • No special-casing for specific operations
  • Breaking change: existing --flag=value syntax for required params will no longer work. Since airflowctl is new and not yet stable, this should be acceptable.

Open question

Posted a clarifying question on the issue about whether all required params should be positional (e.g., xcom add has 5 positional args), or if we should limit it.

closes: #60142


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

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

apache#60142)

Required non-boolean parameters in auto-generated CLI commands are now
positional instead of flag-style, improving UX consistency with manually
defined commands like `dags pause`.

For primitive params parsed via AST, uses default detection to determine
positional vs flag. For Pydantic model fields, uses `is_required()`.
@shivaam shivaam force-pushed the fix/positional-params-airflowctl-60142 branch from 4a30b1e to 8c4f945 Compare April 6, 2026 21:58
Copy link
Copy Markdown
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I addressed your question. Could you please amend it to be both optional and positional, live side by side?
This way, we won't break anything while working, but rather add Airflow CLI positional arguments to improve parity and make migrations easier.

@@ -0,0 +1 @@
Required non-boolean parameters in auto-generated airflowctl commands are now positional instead of flag-style (e.g., ``airflowctl dags get example_dag`` instead of ``airflowctl dags get --dag-id=example_dag``).
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.

This news fragment is for Airflow Core and not related to anything within airflowctl flow.
Since we are still in 0.x, significant changes are also expected at a certain level.
We are logging these things in the release notes

https://airflow.apache.org/docs/apache-airflow-ctl/stable/release_notes.html#significant-changes

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make positional parameters as a destionation paramater for auto-generated commands

2 participants