Skip to content

fix: keep raw values when editing JSON-looking items - #71

Merged
alitariksahin merged 4 commits into
masterfrom
DX-3147-raw-values
Nov 11, 2026
Merged

alitariksahin merged 4 commits into
masterfrom
DX-3147-raw-values

Conversation

@ytkimirti

@ytkimirti ytkimirti commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Bug: Editing a zset score or hash value renamed the member/field, and values like 12345678901234567890 or 10.00 were shown and saved wrong. The value editor wrote JSON.stringify(JSON.parse(value), null, 2) into the form for anything that parses as JSON, so the "edited" name no longer matched the stored one (remove + add) and numbers went through JS doubles.
Fix: The form keeps the stored bytes; JSON is pretty-printed for display only.

Why each change

  • components/databrowser/components/display/input/format-json.ts: a formatter that only changes whitespace outside strings, so formatting can never alter numbers, escapes or key order the way parse + stringify does. It takes the native path when the value is already canonical compact JSON, where native formatting is lossless and faster.
  • format-json.ts getJSONSource / toStoredValue: the untouched formatted view maps back to the original bytes, so opening and saving without edits writes exactly what was stored. Edits to values stored compact are compacted again, so display indentation isn't saved into them.
  • components/databrowser/components/display/input/use-field.tsx: the form value is now the stored value; the editor shows the formatted view, or after typing the exact typed text (kept together with the value it maps to, so the editor doesn't reformat under the cursor). This replaces the effects that overwrote the form with formatted JSON.
  • components/databrowser/components/display/input/content-type-select.tsx: checkIsValidJSON moved next to the formatter.
  • format-json.test.ts: locks in lossless formatting (scalars, big numbers, key order) and the stored-value mapping.

Repro: ZADD z 100 '{"id":1}', open z, change only the score to 200, Save: the member is now the pretty-printed string. SET s 12345678901234567890: the editor shows 12345678901234567000.

Part of DX-3147

@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-redis-browser Ready Ready Preview Oct 28, 2026 7:59am UTC

Request Review

@ytkimirti
ytkimirti marked this pull request as ready for review October 28, 2026 08:03
@alitariksahin
alitariksahin merged commit 81aca01 into master Nov 11, 2026
5 of 6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 072173e4 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants