Skip to content

Fix variables import with structured falsy values - #67060

Merged
bugraoz93 merged 4 commits into
apache:mainfrom
Leondon9:codex/variables-import-20260517
Jun 8, 2026
Merged

bugraoz93 merged 4 commits into
apache:mainfrom
Leondon9:codex/variables-import-20260517

Conversation

@Leondon9

Copy link
Copy Markdown
Contributor

Fix variable import handling for structured falsy values.

This keeps core CLI and airflowctl import semantics aligned when a variable entry is shaped like {"value": ..., "description": ...} and the value is falsy, such as an empty string, 0, false, or null.

It also makes airflowctl variables import reject non-object JSON input with the existing invalid-file error instead of failing later while iterating.

Tests:

  • breeze run pytest airflow-ctl/tests/airflow_ctl/ctl/commands/test_variable_command.py -xvs
  • breeze run pytest airflow-core/tests/unit/cli/commands/test_variable_command.py::TestCliVariables::test_variables_import_with_structured_falsy_values -xvs
  • prek run ruff --files airflow-core/src/airflow/cli/commands/variable_command.py airflow-core/tests/unit/cli/commands/test_variable_command.py airflow-ctl/src/airflowctl/ctl/commands/variable_command.py airflow-ctl/tests/airflow_ctl/ctl/commands/test_variable_command.py

Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-5)

Generated-by: Codex (GPT-5) following the guidelines

@potiuk

potiuk commented May 24, 2026

Copy link
Copy Markdown
Member

@Leondon9 A few things need addressing before review — see our Pull Request quality criteria.

  • ❌ CI fails: Airflow CTL tests / airflow-ctl:P3.10 tests (and possibly other checks — see the Checks tab for the full list).

No rush.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.


Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting

@potiuk potiuk added the ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. label Jun 3, 2026

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed end-to-end — correct and well-targeted. The bug is the truthiness check v.get("value"), which dropped structured entries whose value is falsy ("", 0, false, null) and stored the whole {value, description} dict instead; "value" in v membership fixes it, and serialize_json=not isinstance(value, str) stays consistent (empty-string → no serialize, others → serialize), exactly as the parametrized test asserts. The airflowctl side sensibly rejects non-object JSON up front instead of failing mid-iteration, and soft_wrap=True keeps long file paths intact in the error. Both behaviors are tested.

One note on the newsfragment thread: keeping 67060.bugfix.rst is correct here. airflow-core does consume newsfragments via towncrier at release, and this is a user-facing CLI bugfix — exactly the case that warrants one. (The "generated at release / not needed per PR" convention applies to providers and airflow-ctl, whose release managers regenerate changelogs from git log — not airflow-core.) So it can stay as-is.

LGTM.


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-docs/05_pull_requests.rst.


Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting

@bugraoz93
bugraoz93 force-pushed the codex/variables-import-20260517 branch from 57b8fd2 to 20c4350 Compare June 8, 2026 18:22
@bugraoz93
bugraoz93 merged commit 837bfde into apache:main Jun 8, 2026
6 checks passed
@github-actions

github-actions Bot commented Jun 8, 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

aws-airflow-bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 8, 2026
…y values (apache#67060)

* Fix variables import with structured falsy values

* Add newsfragment for variables import fix

* Fix airflowctl variable import error path wrapping

* Remove unnecessary variables import newsfragment
(cherry picked from commit 837bfde)

Co-authored-by: leon.jeon <[email protected]>
bugraoz93 pushed a commit that referenced this pull request Jun 10, 2026
…y values (#67060) (#68247)

* Fix variables import with structured falsy values

* Add newsfragment for variables import fix

* Fix airflowctl variable import error path wrapping

* Remove unnecessary variables import newsfragment
(cherry picked from commit 837bfde)

Co-authored-by: leon.jeon <[email protected]>
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.3.0 milestone Jun 15, 2026
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Jun 15, 2026
shahar1 pushed a commit that referenced this pull request Nov 19, 2026
…y values (#67060) (#68247)

* Fix variables import with structured falsy values

* Add newsfragment for variables import fix

* Fix airflowctl variable import error path wrapping

* Remove unnecessary variables import newsfragment
(cherry picked from commit 837bfde)

Co-authored-by: leon.jeon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:airflow-ctl area:CLI backport-to-airflow-ctl/v0-1-test ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants