Skip to content

Conversation

guan404ming
Copy link
Contributor

@guan404ming guan404ming commented May 25, 2025

Related Issue

fixes #51052
cc @pierrejeambrun @bugraoz93

Why

The API doesn’t explicitly serialize them as JSON when saving these variables. Instead, Python’s built-in str() function is used to convert the object and str() defaults to using single quotes.

How

Before saving a variable, it checks the value’s type. If the value is a dict or list, call Variable.set with serialize_json=True to ensure that json.dumps is used for proper JSON serialization.

before

Screen.Recording.2025-05-26.at.1.44.03.AM.mov

after

Screen.Recording.2025-05-26.at.1.46.34.AM.mov

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@guan404ming guan404ming force-pushed the fix-json-serialization branch from 0e056ae to 358804a Compare May 26, 2025 10:28
Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Thanks. Nice catch!

@pierrejeambrun pierrejeambrun added the backport-to-v3-0-test Mark PR with this label to backport to v3-0-test branch label May 27, 2025
@pierrejeambrun pierrejeambrun added this to the Airflow 3.0.2 milestone May 27, 2025
@pierrejeambrun pierrejeambrun merged commit 1a34a42 into apache:main May 27, 2025
97 checks passed
github-actions bot pushed a commit that referenced this pull request May 27, 2025
…51057)

(cherry picked from commit 1a34a42)

Co-authored-by: Guan Ming(Wesley) Chiu <[email protected]>
Copy link

Backport successfully created: v3-0-test

Status Branch Result
v3-0-test PR Link

@guan404ming guan404ming deleted the fix-json-serialization branch May 27, 2025 13:08
@guan404ming
Copy link
Contributor Author

guan404ming commented May 27, 2025

Thanks for all reviews.

github-actions bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request May 27, 2025
github-actions bot pushed a commit to guan404ming/airflow that referenced this pull request May 27, 2025
pierrejeambrun pushed a commit that referenced this pull request May 27, 2025
kaxil pushed a commit that referenced this pull request Jun 3, 2025
sanederchik pushed a commit to sanederchik/airflow that referenced this pull request Jun 7, 2025
jose-lehmkuhl pushed a commit to jose-lehmkuhl/airflow that referenced this pull request Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API backport-to-v3-0-test Mark PR with this label to backport to v3-0-test branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(") to (') conversion in import variables is messing up the json value in Airflow 3
6 participants