Skip to content

fix Preserve variable value formatting in edit dialog#58757

Merged
Lee-W merged 3 commits intoapache:mainfrom
ricky-chaoju:fix-variable-formatting-issue-58648
Nov 29, 2025
Merged

fix Preserve variable value formatting in edit dialog#58757
Lee-W merged 3 commits intoapache:mainfrom
ricky-chaoju:fix-variable-formatting-issue-58648

Conversation

@ricky-chaoju
Copy link
Copy Markdown
Contributor

Description

This PR fixes the variable editor to preserve JSON formatting when editing variables in the Airflow UI.

Problem:
In Airflow 3.x, variable values are displayed as minified single-line strings in the edit dialog, making it difficult to read and edit structured data like JSON and YAML.

Solution:
Added a formatValue function in EditVariableButton.tsx that formats JSON values with proper indentation (2 spaces) when the edit dialog is opened. Non-JSON values are preserved as-is.

Changes:

  • Modified EditVariableButton.tsx to add formatValue function
  • JSON values are formatted using JSON.stringify(parsed, null, 2)
  • Non-JSON values are displayed unchanged

Testing:

  1. Created test variable with formatted JSON
  2. Verified formatting is preserved in edit dialog
  3. Tested with YAML values - preserved as-is

Screenshots:

Before:
Value field shows: {"key": "val", "key2": "val2"}
截圖 2025-11-27 下午2 28 11

After:
Value field shows:

{
  "key": "val",
  "key2": "val2"
}
截圖 2025-11-27 下午2 29 14

Related Issue(s):
Closes #58648

)

When editing variables in the UI, JSON values are now displayed
with proper formatting (indentation and line breaks) instead of
being shown as minified single-line strings.

This restores the behavior from Airflow 2.x where variable values
were displayed with their original formatting.

Fixes apache#58648
@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Nov 27, 2025
Copy link
Copy Markdown
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

I'm good with this change but would be nice if we can have frontend expert take a look. Thanks!

@Lee-W Lee-W changed the title fix Preserve variable value formatting in edit dialog (#58648) fix Preserve variable value formatting in edit dialog Nov 27, 2025
@Lee-W Lee-W merged commit f697a0b into apache:main Nov 29, 2025
60 checks passed
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg bot commented Nov 29, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@ricky-chaoju ricky-chaoju deleted the fix-variable-formatting-issue-58648 branch November 29, 2025 11:26
@ricky-chaoju
Copy link
Copy Markdown
Contributor Author

Thanks @Lee-W for the review and merge.

RoyLee1224 pushed a commit to RoyLee1224/airflow that referenced this pull request Dec 3, 2025
Copilot AI pushed a commit to jason810496/airflow that referenced this pull request Dec 5, 2025
itayweb pushed a commit to itayweb/airflow that referenced this pull request Dec 6, 2025
@ctolon
Copy link
Copy Markdown

ctolon commented Feb 16, 2026

Hi, Is this addressed in PR for Apache Airflow 3.2? It's a significant update from a developer UX perspective

Lee-W pushed a commit to astronomer/airflow that referenced this pull request Feb 23, 2026
Lee-W pushed a commit to astronomer/airflow that referenced this pull request Feb 23, 2026
…ache#58757)

(cherry picked from commit f697a0b)

Co-authored-by: RickyChen / 陳昭儒 <109416633+rickychen-infinirc@users.noreply.github.com>
Lee-W pushed a commit to astronomer/airflow that referenced this pull request Feb 23, 2026
@Lee-W
Copy link
Copy Markdown
Member

Lee-W commented Feb 23, 2026

looks like a valid backport. just create a backport PR here #62339

Lee-W added a commit that referenced this pull request Feb 23, 2026
Co-authored-by: RickyChen / 陳昭儒 <109416633+rickychen-infinirc@users.noreply.github.com>
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
vatsrahul1001 pushed a commit that referenced this pull request Mar 4, 2026
Co-authored-by: RickyChen / 陳昭儒 <109416633+rickychen-infinirc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable value formatting no longer preserved in Airflow 3.x UI

4 participants