Skip to content

[v3-3-test] Stop variables export/import from silently corrupting values (#70944) - #71791

Merged
potiuk merged 1 commit into
v3-3-testfrom
backport-f549b34-v3-3-test
Aug 30, 2026
Merged

potiuk merged 1 commit into
v3-3-testfrom
backport-f549b34-v3-3-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor
  • Stop variables export/import from silently corrupting values

airflow variables export writes a bare value for any variable without a
description, while airflow variables import treats every dict carrying a
"value" key as a {"value": ..., "description": ...} envelope. A variable whose
own value happens to have that shape is therefore unwrapped on the way back in:
its value is replaced by the inner "value" and a description is invented from
the inner "description". Nothing warns the operator, so a round-trip through a
file - the documented way to migrate variables between environments - quietly
rewrites their data.

Export also decodes the stored JSON before writing it out, which erases the
difference between a variable holding raw text and one holding a JSON-encoded
string. Re-importing flattens the latter, and any Dag reading it with
deserialize_json=True starts failing on a value that is no longer valid JSON.

Import's reconstruction is deterministic - strings are stored verbatim,
everything else is JSON-encoded, and one envelope layer is unwrapped - so export
alone can be made lossless. Fixing it there leaves import untouched and keeps
hand-written import files working exactly as before.

  • apply suggestion

(cherry picked from commit f549b34)

Co-authored-by: Y-C easoneason0905@gmail.com
Co-authored-by: Eason09053360 185830721+Eason09053360@users.noreply.github.com

…ues (#70944)

* Stop variables export/import from silently corrupting values

`airflow variables export` writes a bare value for any variable without a
description, while `airflow variables import` treats every dict carrying a
"value" key as a {"value": ..., "description": ...} envelope. A variable whose
own value happens to have that shape is therefore unwrapped on the way back in:
its value is replaced by the inner "value" and a description is invented from
the inner "description". Nothing warns the operator, so a round-trip through a
file - the documented way to migrate variables between environments - quietly
rewrites their data.

Export also decodes the stored JSON before writing it out, which erases the
difference between a variable holding raw text and one holding a JSON-encoded
string. Re-importing flattens the latter, and any Dag reading it with
deserialize_json=True starts failing on a value that is no longer valid JSON.

Import's reconstruction is deterministic - strings are stored verbatim,
everything else is JSON-encoded, and one envelope layer is unwrapped - so export
alone can be made lossless. Fixing it there leaves import untouched and keeps
hand-written import files working exactly as before.

* apply suggestion

---------
(cherry picked from commit f549b34)

Co-authored-by: Y-C <easoneason0905@gmail.com>
Co-authored-by: Eason09053360 <185830721+Eason09053360@users.noreply.github.com>
@potiuk
potiuk force-pushed the backport-f549b34-v3-3-test branch from 25789f4 to d5de698 Compare August 29, 2026 19:09
@potiuk
potiuk marked this pull request as ready for review August 29, 2026 19:09

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

Clean cherry-pick of #70944 — verified the patch is byte-identical to the original commit on main (only blob hashes and hunk offsets differ). Rebased onto current v3-3-test, CI green.


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

@potiuk
potiuk merged commit e5f8597 into v3-3-test Aug 30, 2026
102 of 126 checks passed
@potiuk
potiuk deleted the backport-f549b34-v3-3-test branch August 30, 2026 00:01
@github-actions github-actions Bot added this to the Airflow 3.3.2 milestone Aug 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.3.2 based on: merged to version branch
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:CLI type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants