Skip to content

Show the JSON parse-error message on the Variable form warning - #71780

Draft
pierrejeambrun wants to merge 1 commit into
apache:mainfrom
astronomer:show-json-parse-error-location
Draft

Show the JSON parse-error message on the Variable form warning#71780
pierrejeambrun wants to merge 1 commit into
apache:mainfrom
astronomer:show-json-parse-error-location

Conversation

@pierrejeambrun

Copy link
Copy Markdown
Member

The Variables form warns "Invalid JSON" the moment the value looks like it might be JSON but doesn't parse. That warning tells the user something's wrong but not where, so a typo halfway through a large value is still a hunt.

The browser's SyntaxError from JSON.parse already carries the position ("Unexpected token ',' at position 42 (line 3 column 12)" on V8; similar on Firefox / Safari). Surface it alongside the localized label so users can jump straight to the character that broke the parse.

Caveat worth naming up front. The parser message is emitted by the JS engine and is only ever in English — mixing it with a localized label is a compromise. The position info is more valuable than perfect localization here IMO, and no browser offers a localized JSON parse error to begin with. Alternative would be a dependency like jsonc-parser for a cross-browser structured error, which is ~30KB for a UI hint.

Existing test cases (Jinja template {{ var.value.x }}, bracket-prefixed plain string [DRAFT] ..., malformed object with trailing comma) still hit the same warning path — just with a browser-provided detail message now. Updated the getByText assertions to a regex so they don't depend on the exact detail suffix, which varies by browser.

closes: #68262

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7) following the guidelines

The Variables form warns "Invalid JSON" the moment the value looks
like it might be JSON but doesn't parse. That warning tells the user
something's wrong but not where, so a typo halfway through a large
value is still a hunt.

The browser's SyntaxError from JSON.parse already carries the position
("Unexpected token ',' at position 42 (line 3 column 12)" on V8,
similar on Firefox / Safari). Surface it alongside the localized label
so users can jump straight to the character that broke the parse.

The parser message is emitted by the JS engine and is only ever in
English — mixing it with a localized label is a compromise, but the
position info is more valuable than perfect localization here, and no
browser offers a localized JSON parse error to begin with.

closes: apache#68262
@boring-cyborg boring-cyborg Bot added the area:UI Related to UI/UX. For Frontend Developers. label Aug 18, 2026
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.

Make the "Invalid JSON" validation warning on the Edit Variable form more prominent (and block/guard Save)

1 participant