Skip to content

Escape error text in airflowctl safe_call_command messages - #76264

Merged
shahar1 merged 1 commit into
apache:mainfrom
Rishabh00b:escape-markup-in-safe-call-command
Nov 3, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
Rishabh00b:escape-markup-in-safe-call-command

Conversation

@Rishabh00b

@Rishabh00b Rishabh00b commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

airflowctl's central error handler prints exception and server error text through Rich markup without escaping it. If the text contains a tag-like fragment such as [/x], rich.print raises MarkupError. The user then sees a traceback instead of the real failure, and the command no longer exits with status 1.

The text is now escaped in the AirflowCtl, protocol, timeout, server response and HTTP status handlers. This is the same class of bug fixed for table output in #76175.

Tests: parametrized over the five handler types; all five fail without the change.


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

@Andrushika Andrushika 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.

Small thing in the description: on main the command still exits with status 1, because the MarkupError is an uncaught exception. The user-visible change is the traceback in place of the server error, so maybe drop the exit-status part.

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

LGTM — the five safe_call_command handlers now escape the exception text before it reaches Rich, with a parametrized regression test that fails on main (reproduced: rich.errors.MarkupError: closing tag '[/bogus]' at position 32 doesn't match any open tag), CI green.

Smaller observations

  • PR description: as Andrushika noted, on main the command still exits with status 1, because an uncaught MarkupError makes Python exit 1. The user-visible regression is the traceback in place of the real error. Worth dropping the exit-status clause before merge, since the description becomes the squash commit message.
  • Follow-up, not for this PR: the same unescaped {e} interpolation remains in airflow-ctl/src/airflowctl/ctl/commands/auth_command.py (lines 95 and 158), dag_command.py (lines 58 and 119) and config_command.py (line 841). Those print server or exception text through Rich markup too, so they can hit the same MarkupError.

This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Airflow handles maintainer review:
Contributing guide.

Drafted-by: Claude Code (Claude Fable 5.1); reviewed by shahar1 before posting

safe_call_command interpolated exception and server error text straight
into Rich markup. A message containing a tag-like fragment such as
"[/x]" made rich.print raise MarkupError, so the user saw a traceback
instead of the real failure and the exit code was no longer 1.

Escape the text in the AirflowCtl, protocol, timeout, server response
and HTTP status handlers.
@shahar1
shahar1 force-pushed the escape-markup-in-safe-call-command branch from 56214f2 to 46a7c0b Compare November 3, 2026 16:03
@shahar1
shahar1 enabled auto-merge (squash) November 3, 2026 16:04
@shahar1

shahar1 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Pushed a fix to resolve conflicts

@shahar1
shahar1 merged commit ab39e95 into apache:main Nov 3, 2026
92 checks passed
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Backport successfully created: airflow-ctl/v0-1-test

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

shahar1 pushed a commit that referenced this pull request Nov 3, 2026
…mand messages (#76264) (#76385)

safe_call_command interpolated exception and server error text straight
into Rich markup. A message containing a tag-like fragment such as
"[/x]" made rich.print raise MarkupError, so the user saw a traceback
instead of the real failure and the exit code was no longer 1.

Escape the text in the AirflowCtl, protocol, timeout, server response
and HTTP status handlers.
(cherry picked from commit ab39e95)

Co-authored-by: Rishabh <Rishabh00b@gmail.com>
shahar1 pushed a commit to shahar1/airflow that referenced this pull request Nov 4, 2026
…mand messages (apache#76264) (apache#76385)

safe_call_command interpolated exception and server error text straight
into Rich markup. A message containing a tag-like fragment such as
"[/x]" made rich.print raise MarkupError, so the user saw a traceback
instead of the real failure and the exit code was no longer 1.

Escape the text in the AirflowCtl, protocol, timeout, server response
and HTTP status handlers.
(cherry picked from commit ab39e95)

Co-authored-by: Rishabh <Rishabh00b@gmail.com>
@Rishabh00b
Rishabh00b deleted the escape-markup-in-safe-call-command branch November 7, 2026 08:38
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.

3 participants