bramhanandlingala opened a new pull request, #68387:
URL: https://github.com/apache/airflow/pull/68387
## Summary
Fixes #<issue-number> — operators could save malformed JSON variable values
without a clear warning, causing silent DAG failures at runtime.
## Problem
When a variable value looked like JSON (starts with `{` or `[`) but was
invalid, the UI showed a small plain-text "Invalid JSON" message that was easy
to miss. The Save button stayed enabled, so the broken value could be persisted
without the user noticing.
## Changes
- Replaced `isJsonString` (silent boolean) with `validateJson`, which
captures the `SyntaxError` message from `JSON.parse` and surfaces the exact
parse error location (e.g. `Unexpected token } at position 12`) in the field
error text
- Added `FiAlertCircle` icon to all `Field.ErrorText` error messages for
visual prominence
- Save button is now blocked when the value fails JSON validation —
`react-hook-form` marks the form invalid when `validate` returns a string,
which flows into `disabled={!isValid || isPending}`
- Plain string values (not starting with `{` or `[`) are unaffected and
remain saveable as before
- Fixed `useConfig` hook call separated from `Boolean()` wrapper to comply
with React Rules of Hooks
- Added `field.value ?? ""` fallback on `Textarea` fields to prevent
uncontrolled → controlled input warnings
- Removed redundant `.tsx` extensions from local imports
- Removed redundant native `required` prop on `Input` (handled by
react-hook-form rules)
## Testing
- Enter a value starting with `{` or `[` with invalid JSON (e.g. `{"key":}`)
- Red border appears on the textarea via `Field.Root invalid`
- Error message shows with icon and exact parse error position
- Save button is disabled
- Fix the JSON → Save re-enables
- Enter a plain string value (not `{` or `[`) → saves normally with no JSON
validation applied
--
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]