Skip to content

Report invalid variables in airflowctl variables import as readable e… - #76174

Merged
shahar1 merged 1 commit into
apache:mainfrom
Rishabh00b:report-invalid-variable-in-airflowctl-import
Nov 1, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
Rishabh00b:report-invalid-variable-in-airflowctl-import

Conversation

@Rishabh00b

@Rishabh00b Rishabh00b commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

A variable with a bad value, such as a non-string description or a blank or over-long key, crashed airflowctl variables import with a raw pydantic traceback that did not say which variable was wrong. Report the variable key, the file and the reason instead, as airflowctl connections import already does.

Three new parametrized tests in test_variable_command.py fail without this change and pass with it.


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

Generated-by: Claude Code (Sonnet 5.5) following the guidelines

…rrors

A variable with a bad value, such as a non-string description or a blank
or over-long key, crashed `airflowctl variables import` with a raw
pydantic traceback that did not say which variable was wrong. Report the
variable key, the file and the reason instead, as
`airflowctl connections import` already does.

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

Clean fix that mirrors the connections import error path: it reuses split_validation_errors, escapes the key and file path for Rich markup, and each new test case fails without the change (pydantic's ValidationError escapes instead of SystemExit). Discarding missing is safe here: key always arrives as a string from the JSON object and value: JsonValue accepts null, so no required field can be reported as missing.

Two small notes, neither blocking:

  • PR title is truncated (…as readable e…). It becomes the squash commit subject, so please give it the full wording, for example Report invalid variables in airflowctl variables import as readable errors.
  • Backport to airflow-ctl/v0-1-test: on that branch VariableBody.key has no pattern="\\S" constraint, so the blank-key case will not raise there and the cherry-picked test will fail. The backport PR needs to drop that case (the other two cases and the code change apply as-is; split_validation_errors already exists on the branch).

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.

@shahar1
shahar1 merged commit 122f7b4 into apache:main Nov 1, 2026
120 of 135 checks passed
@github-actions

github-actions Bot commented Nov 1, 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

github-actions Bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Nov 1, 2026
…les import as readable errors (apache#76174)

A variable with a bad value, such as a non-string description or a blank
or over-long key, crashed `airflowctl variables import` with a raw
pydantic traceback that did not say which variable was wrong. Report the
variable key, the file and the reason instead, as
`airflowctl connections import` already does.
(cherry picked from commit 122f7b4)

Co-authored-by: Rishabh <[email protected]>
shahar1 added a commit that referenced this pull request Nov 1, 2026
…les import as readable errors (#76174) (#76196)

* [airflow-ctl/v0-1-test] Report invalid variables in airflowctl variables import as readable errors (#76174)

A variable with a bad value, such as a non-string description or a blank
or over-long key, crashed `airflowctl variables import` with a raw
pydantic traceback that did not say which variable was wrong. Report the
variable key, the file and the reason instead, as
`airflowctl connections import` already does.
(cherry picked from commit 122f7b4)

Co-authored-by: Rishabh <[email protected]>

* Drop the blank-key import test case from the v0-1-test backport

The blank-key case relies on the pattern constraint that #74896 added to VariableBody.key. That change is not on airflow-ctl/v0-1-test: the branch models follow the 3.2 spec, and Airflow 3.2 and 3.3 servers accept a whitespace-only key.

---------

Co-authored-by: Rishabh <[email protected]>
Co-authored-by: Shahar Epstein <[email protected]>
@Rishabh00b
Rishabh00b deleted the report-invalid-variable-in-airflowctl-import branch November 1, 2026 14:27
shahar1 added a commit that referenced this pull request Nov 19, 2026
…les import as readable errors (#76174) (#76196)

* [airflow-ctl/v0-1-test] Report invalid variables in airflowctl variables import as readable errors (#76174)

A variable with a bad value, such as a non-string description or a blank
or over-long key, crashed `airflowctl variables import` with a raw
pydantic traceback that did not say which variable was wrong. Report the
variable key, the file and the reason instead, as
`airflowctl connections import` already does.
(cherry picked from commit 122f7b4)

Co-authored-by: Rishabh <[email protected]>

* Drop the blank-key import test case from the v0-1-test backport

The blank-key case relies on the pattern constraint that #74896 added to VariableBody.key. That change is not on airflow-ctl/v0-1-test: the branch models follow the 3.2 spec, and Airflow 3.2 and 3.3 servers accept a whitespace-only key.

---------

Co-authored-by: Rishabh <[email protected]>
Co-authored-by: Shahar Epstein <[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