Repository navigation
[v3-3-test] Stop variables export/import from silently corrupting values (#70944) - #71791
Merged
Merged
Conversation
1 task done
…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
force-pushed
the
backport-f549b34-v3-3-test
branch
from
August 29, 2026 19:09
25789f4 to
d5de698
Compare
potiuk
marked this pull request as ready for review
August 29, 2026 19:09
potiuk
requested review from
bugraoz93,
dheerajturaga,
henry3260 and
potiuk
as code owners
August 29, 2026 19:09
potiuk
approved these changes
Aug 30, 2026
Contributor
Author
|
Hi maintainer, this PR was merged without a milestone set.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
airflow variables exportwrites a bare value for any variable without adescription, while
airflow variables importtreats 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.
(cherry picked from commit f549b34)
Co-authored-by: Y-C easoneason0905@gmail.com
Co-authored-by: Eason09053360 185830721+Eason09053360@users.noreply.github.com