Skip to content

Keep airflowctl dags pause/unpause/drain output parseable - #76133

Merged
shahar1 merged 1 commit into
apache:mainfrom
Shawnsuun:airflowctl-dags-state-stdout
Oct 31, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
Shawnsuun:airflowctl-dags-state-stdout

Conversation

@Shawnsuun

Copy link
Copy Markdown
Contributor

airflowctl dags pause|unpause|drain printed Dag <operation> successful <dag_id> and
Further Dag details: to stdout before the --output data, so
airflowctl dags pause my_dag -o json | jq . failed: stdout was not valid JSON. The error
message on failure (Error while trying to <operation> Dag ...) also went to stdout.

These status and error lines now go to stderr, the same way airflowctl already reports the
"request may already have been applied" warning. Stdout carries only the requested output
format. In a terminal, the visible output does not change. The status lines still show for
every output format, but on stderr.

Tests: parametrized over pause/unpause/drain, they check that -o json stdout parses as JSON
while the status lines are on stderr, and that the failure message is on stderr and not on
stdout. The airflow-ctl-tests integration runner merges stderr into stdout, so the
dags pause/unpause/drain example_bash_operator integration commands are unaffected.

Note: on an API error, the client's generic Server error warning is still logged through the
default structlog configuration, which writes to stdout. That affects every command, not just
these three, and is left for a separate change.

related: #66139


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: GitHub Copilot (Claude Opus 5.5) following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

The "Dag <operation> successful" and "Further Dag details:" status lines,
and the error message on failure, were printed to stdout ahead of the
--output data. That made `airflowctl dags pause <dag_id> -o json` produce
output that is not valid JSON, so piping it to jq or json.loads failed.
Status and error text belong on stderr, matching how the CLI already
reports the ambiguous-write warning, so stdout carries only the requested
output format.

@shahar1 shahar1 left a comment

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.

Great job!

@shahar1
shahar1 merged commit 956d8cd into apache:main Oct 31, 2026
91 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 956d8cd 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.

shahar1 added a commit that referenced this pull request Oct 31, 2026
…ut parseable (#76133) (#76172)

The "Dag <operation> successful" and "Further Dag details:" status lines, and the error message on failure, were printed to stdout ahead of the --output data. That made `airflowctl dags pause <dag_id> -o json` produce output that is not valid JSON, so piping it to jq or json.loads failed. Status and error text belong on stderr, matching how the CLI already reports the ambiguous-write warning, so stdout carries only the requested output format.

Backport note: this branch has no `dags drain`, so the drain cases of the new tests were dropped; the source change is identical to main.

(cherry picked from commit 956d8cd)

Co-authored-by: Shawn Sun <[email protected]>
shahar1 pushed a commit that referenced this pull request Nov 3, 2026
…76347)

The API client logs "Server error" and the tenacity retry warning
through structlog, which prints to stdout when nothing configures it.
A single retried 5xx then puts two log lines in front of the
`-o json` output, while the command still exits 0. The shared error
handler also printed its messages to stdout. #76133 and #76134 moved
the messages of a few commands to stderr, but these two paths are
shared by every command.
shahar1 pushed a commit that referenced this pull request Nov 3, 2026
…st is retried or fails (#76347) (#76380)

The API client logs "Server error" and the tenacity retry warning
through structlog, which prints to stdout when nothing configures it.
A single retried 5xx then puts two log lines in front of the
`-o json` output, while the command still exits 0. The shared error
handler also printed its messages to stdout. #76133 and #76134 moved
the messages of a few commands to stderr, but these two paths are
shared by every command.
(cherry picked from commit 6f7cb34)

Co-authored-by: Andrew Chang <[email protected]>
shahar1 pushed a commit to shahar1/airflow that referenced this pull request Nov 4, 2026
…st is retried or fails (apache#76347) (apache#76380)

The API client logs "Server error" and the tenacity retry warning
through structlog, which prints to stdout when nothing configures it.
A single retried 5xx then puts two log lines in front of the
`-o json` output, while the command still exits 0. The shared error
handler also printed its messages to stdout. apache#76133 and apache#76134 moved
the messages of a few commands to stderr, but these two paths are
shared by every command.
(cherry picked from commit 6f7cb34)

Co-authored-by: Andrew Chang <[email protected]>
shahar1 added a commit that referenced this pull request Nov 19, 2026
…ut parseable (#76133) (#76172)

The "Dag <operation> successful" and "Further Dag details:" status lines, and the error message on failure, were printed to stdout ahead of the --output data. That made `airflowctl dags pause <dag_id> -o json` produce output that is not valid JSON, so piping it to jq or json.loads failed. Status and error text belong on stderr, matching how the CLI already reports the ambiguous-write warning, so stdout carries only the requested output format.

Backport note: this branch has no `dags drain`, so the drain cases of the new tests were dropped; the source change is identical to main.

(cherry picked from commit 956d8cd)

Co-authored-by: Shawn Sun <[email protected]>
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.

2 participants