Repository navigation
Open
Labels
Description
Under which category would you file this issue?
Airflow Core
Apache Airflow version
3.2.0
What happened and how to reproduce it?
Issue Description
When running an Airflow CLI command with JSON output, logs are printed before the JSON payload.
For example:
airflow dags list -o json
prints Airflow/Alembic log lines before the JSON array starts.
This makes the output invalid JSON and breaks standard command-line tools such as jq.
## Steps to reproduce
1. Run:
airflow dags list -o json
2. Try to parse the output with jq:
airflow dags list -o json | jq
3. Or redirect the output to a file:
airflow dags list -o json > /tmp/output.json 2>&1
head -10 /tmp/output.json
## Observed behavior
The command outputs log lines before the JSON content, for example:
2026-04-30T01:14:29.770306Z [info] setup plugin alembic.autogenerate.schemas
2026-04-30T01:14:29.770491Z [info] setup plugin alembic.autogenerate.tables
2026-04-30T01:14:29.922347Z [warning] Could not import graphviz...
[{"dag_id": "SAFE_MODE_TEST_66104", ...}]
Because the output does not start with valid JSON, parsing fails:
jq: parse error: Invalid numeric literal at line 1, column 14
The failed pipe can also produce a Python BrokenPipeError traceback.
##Screenshots
##JSON parsing failure with jq
<img width="921" height="723" alt="Image" src="https://github.com/user-attachments/assets/652702b7-1e86-4c6c-a592-be8217e6e73f" />
##Raw JSON output polluted by logs
<img width="918" height="806" alt="Image" src="https://github.com/user-attachments/assets/7a0ae3d9-2dac-4755-8899-5cf89b3dbc3a" />
##Redirected output file starts with logs instead of JSON
<img width="937" height="860" alt="Image" src="https://github.com/user-attachments/assets/b537d35d-bf4a-48ae-8c07-d4276c2ca6e3" />
### What you think should happen instead?
When using `-o json`, the command output should be valid JSON that can be parsed directly by tools such as `jq`.
Logs and warnings should not be written to the same output stream as the JSON payload. They should either be suppressed for machine-readable output or written to stderr so stdout remains valid JSON.
### Operating System
Ubuntu 24.04.4 LTS (WSL2)
### Deployment
Virtualenv installation
### Apache Airflow Provider(s)
standard
### Versions of Apache Airflow Providers
apache-airflow-providers-common-compat==1.14.3
apache-airflow-providers-common-io==1.7.2
apache-airflow-providers-common-sql==1.34.0
apache-airflow-providers-smtp==2.4.5
apache-airflow-providers-standard==1.12.3
### Official Helm Chart version
Not Applicable
### Kubernetes Version
_No response_
### Helm Chart configuration
_No response_
### Docker Image customizations
_No response_
### Anything else?
This occurs consistently in my local Airflow 3.2.0 environment.
The issue affects scripting and automation because `-o json` output is expected to be machine-readable.
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
Activity
saidiraja commentedon Apr 30, 2026
Note: This issue is not specific to
jq.Any tool expecting valid JSON fails because the output begins with log lines instead of a JSON array.
Example:
This makes
-o jsonunreliable for automation.FTS18 commentedon May 1, 2026
Hey @saidiraja,
I’ve opened a PR for this: #66223
Handled it at the CLI entry level so logs go to
stderrwhenever-o json/-o yamlis used. This keepsstdoutclean for tools likejq. Also added a regression test to lock this behavior in.Let me know what you think.
bugraoz93 commentedon May 1, 2026
Changes in CLI won't be needed we started moving already with AIP-94
AIP-94: Migration Tooling from Airflow CLI to Airflow CTL (airflowctl)
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=382175838
The CLI will use API and airflowctl under the hood. It will return pure JSON directly from airflowctl
FTS18 commentedon May 1, 2026
I've closed the PR to keep the roadmap clean. I'll take a look at AIP-94 and see if there are areas where I can contribute to the new migration tooling instead. Thanks!!!!
saidiraja commentedon May 3, 2026
Thanks everyone for the discussion and clarification.
That makes sense if the CLI is moving towards AIP-94 and will rely on airflowctl for structured output, then addressing this at the current CLI level may not be necessary.
From my side, the main concern was ensuring that
-o jsonis reliable for automation (e.g., jq, scripts, etc.). If the new tooling guarantees clean JSON output, that would fully address the issue.Happy to keep this open if it's still relevant for the transition period, or close it if it's considered covered by the ongoing migration.
Let me know what you prefer.
parkhojeong commentedon May 4, 2026
thanks for your report. @saidiraja
your issue description has image but preview does not work because of the markdown syntax.
you can fix by adding ``` at the end of bash command

parkhojeong commentedon May 4, 2026
I posted the screenshot earlier
Screenshots
JSON parsing failure with jq
Raw JSON output polluted by logs
Redirected output file starts with logs instead of JSON