Skip to content

Escape Rich markup in airflowctl variable and pool commands - #76419

Merged
shahar1 merged 1 commit into
apache:mainfrom
Kaap10:fix-airflowctl-escape-markup-variable-pool
Nov 4, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
Kaap10:fix-airflowctl-escape-markup-variable-pool

Conversation

@Kaap10

@Kaap10 Kaap10 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Description

User-controlled strings (file paths, imported variable keys, and API error responses) printed with rich.print() or Console().print() can trigger rich.errors.MarkupError when they contain square brackets (e.g. [/x] or directory names like [backup]).

This change escapes:

  • file_path in variable_command._print_file_error (and closes unclosed [red]).
  • result.create.errors and result.create.success in variable_command.import_.
  • args.file in pool_command.export.

Complements #76265 by covering the remaining unescaped commands in airflowctl.

Tests

  • Added test_print_file_error_containing_markup to test_variable_command.py.
  • Added test_import_success_prints_variable_keys_containing_markup to test_variable_command.py.
  • Added test_import_error_containing_markup to test_variable_command.py.
  • Added test_export_json_file_path_containing_markup to test_pool_command.py.

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

Generated-by: Antigravity following the guidelines


Drafted-by: Antigravity; reviewed by @Kaap10 before posting

User-supplied inputs such as file paths, imported variable keys, and server
error responses containing square brackets or Rich markup tags can cause
unhandled rich.errors.MarkupError crashes when printed via rich.print or
Console().print. Escaping these strings ensures special characters are
treated as literal text rather than formatting tags.
@shahar1
shahar1 merged commit 6920d2c into apache:main Nov 4, 2026
93 checks passed
@github-actions

github-actions Bot commented Nov 4, 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 4, 2026
… pool commands (#76419) (#76476)

User-supplied inputs such as file paths, imported variable keys, and server
error responses containing square brackets or Rich markup tags can cause
unhandled rich.errors.MarkupError crashes when printed via rich.print or
Console().print. Escaping these strings ensures special characters are
treated as literal text rather than formatting tags.
(cherry picked from commit 6920d2c)

Co-authored-by: Vardhman Gupta <[email protected]>
shahar1 pushed a commit to shahar1/airflow that referenced this pull request Nov 4, 2026
… pool commands (apache#76419) (apache#76476)

User-supplied inputs such as file paths, imported variable keys, and server
error responses containing square brackets or Rich markup tags can cause
unhandled rich.errors.MarkupError crashes when printed via rich.print or
Console().print. Escaping these strings ensures special characters are
treated as literal text rather than formatting tags.
(cherry picked from commit 6920d2c)

Co-authored-by: Vardhman Gupta <[email protected]>
@Kaap10
Kaap10 deleted the fix-airflowctl-escape-markup-variable-pool branch November 5, 2026 05:13
Rishabh00b added a commit to Rishabh00b/airflow that referenced this pull request Nov 5, 2026
Take the upstream versions of variable_command.py and its tests: apache#76419
already escapes the variables import output.
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