Repository navigation
Report invalid variables in airflowctl variables import as readable e… - #76174
Conversation
…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
left a comment
There was a problem hiding this comment.
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 exampleReport invalid variables in airflowctl variables import as readable errors. - Backport to
airflow-ctl/v0-1-test: on that branchVariableBody.keyhas nopattern="\\S"constraint, so theblank-keycase 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_errorsalready 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.
Backport successfully created: airflow-ctl/v0-1-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…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]>
…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]>
…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]>
A variable with a bad value, such as a non-string description or a blank or over-long key, crashed
airflowctl variables importwith a raw pydantic traceback that did not say which variable was wrong. Report the variable key, the file and the reason instead, asairflowctl connections importalready does.Three new parametrized tests in
test_variable_command.pyfail without this change and pass with it.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Sonnet 5.5) following the guidelines