zachliu opened a new issue, #68262:
URL: https://github.com/apache/airflow/issues/68262

   ### Description
   
   On the Edit Variable modal (Airflow 3.x UI), when a variable's value is not 
valid JSON, the UI displays a small, low-contrast "Invalid JSON" message in 
plain text directly beneath the value textarea. This warning is very easy to 
overlook:
   
   - The text is small and positioned below the input, outside the user's focal 
area when they are looking at the value field or the Save button.
   - There is no accompanying icon, colored banner, or border highlight to draw 
attention.
   - The Save button remains fully enabled and visually unchanged, so the 
message reads as informational rather than as a blocking error.
   
   As a result, a user can edit a variable, introduce a malformed-JSON value 
(e.g. a trailing comma), see no obvious obstacle, click Save, and persist a 
broken value without ever registering that the UI tried to warn them.
   
   <img width="894" height="569" alt="Image" 
src="https://github.com/user-attachments/assets/8ef70123-fa9d-4958-b9c7-7bea76039de4";
 />
   
   Proposed improvements (any subset would help):
   
   1. Elevate the warning to a prominent inline error state, e.g. a red border 
on the textarea, an error icon, and a clearly styled message, consistent with 
how other form validation errors are surfaced.
   2. Disable the Save button (or show a confirmation dialog) while the value 
fails JSON validation, if the variable is intended to be stored as JSON. 
Plain-string variables should still be saveable.
   3. Optionally, point to the location/line of the parse error to help users 
fix it quickly.
   
   ### Use case/motivation
   
   Airflow Variables are frequently used to store JSON configuration that DAGs 
deserialize at runtime via `Variable.get(key, deserialize_json=True)`. These 
variables are often edited directly in the UI by operators who are not the 
original authors of the DAG code.
   
   When a malformed-JSON value is saved:
   
   - The variable is stored as an invalid string.
   - DAGs that deserialize it fail at runtime and depending on the DAG's error 
handling, may silently fall back to a default/empty value rather than failing 
loudly. This can route work to the wrong destination (e.g. a wrong S3 bucket) 
or skip records entirely.
   - The root cause (a single stray character in the variable) is hard to 
trace, because the failure surfaces downstream in the DAG, far from the edit 
action that caused it.
   
   We hit exactly this: an operator edited a JSON variable in the UI, a 
trailing comma made the value invalid, and the "Invalid JSON" warning went 
unnoticed because Save stayed enabled. The variable saved, downstream DAGs fell 
back to a default value, and the failure showed up hours later as a confusing 
"missing S3 bucket" error that took multiple people to diagnose.
   
   A more prominent warning, and ideally a guarded `Save`, would have stopped 
the bad value at the source and prevented the downstream incident entirely. 
This is a small UI change that meaningfully reduces a whole
   class of hard-to-diagnose, operator-introduced production failures.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to