Skip to content

Fix airflow plugins and dags pause printing prose with --output json - #73270

Open
ColtenOuO wants to merge 1 commit into
apache:mainfrom
ColtenOuO:fix-cli-empty-structured-output
Open

ColtenOuO wants to merge 1 commit into
apache:mainfrom
ColtenOuO:fix-cli-empty-structured-output

Conversation

@ColtenOuO

Copy link
Copy Markdown
Contributor

Sumarry

When nothing matched, airflow plugins and airflow dags pause / airflow dags unpause printed a hard-coded prose message ("No plugins loaded", "No unpaused DAGs were found") before reaching AirflowConsole().print_as, so --output json and --output yaml were ignored on that path and callers piping into jq or a YAML parser got output they cannot parse.

The [] output comes from AirflowConsole in airflow-core/src/airflow/cli/simple_table.py: print_as dispatches on --output, and for an empty list print_as_json renders json.dumps([]) and print_as_yaml renders yaml.dump([]), both of which produce [], while print_as_table / print_as_plain_table print "No data found". The other list-style commands (e.g. airflow dags list, airflow pools list, airflow variables list) hand the possibly-empty result straight to print_as and therefore already behave this way, and airflow-core/docs/howto/usage-cli.rst documents it ("the default output when there are no errors is No data found, and the json output is []"). airflow teams list was aligned with that convention in #72945.

This PR makes the two remaining commands follow the same convention for structured output by passing the empty result to print_as for json / yaml.


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

When nothing matched, both commands printed a hard-coded message before reaching AirflowConsole().print_as, so --output json/yaml callers got a prose line that jq and YAML parsers cannot read. Other list-style commands render an empty result as [] for structured formats, as documented in usage-cli.rst, and teams list was aligned with that in apache#72945. The human-readable message is kept for table and plain output, where it is more specific than the generic "No data found".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant