Skip to content

fix(core): escape JSON Pointer keys in flattenToPointers - #345

Open
ROTl24 wants to merge 1 commit into
vercel-labs:mainfrom
ROTl24:fix/flatten-json-pointer-keys
Open

ROTl24 wants to merge 1 commit into
vercel-labs:mainfrom
ROTl24:fix/flatten-json-pointer-keys

Conversation

@ROTl24

@ROTl24 ROTl24 commented Sep 19, 2026 •

Copy link
Copy Markdown

flattenToPointers({ "a/b": 1, a: { b: 2 } }) currently returns only { "/a/b": 2 }: the two keys collide. Keys containing ~ also produce paths that don't read back correctly through store.get. The devtools state tab uses these paths for inline edits, so this can hide an entry or write to a different key.

Escape each key using JSON Pointer's ~0 and ~1 sequences before appending it to the prefix. Added regressions for the collision, nested escaping with an existing prefix, and reading/writing the resulting paths through a state store. All three fail before the fix and pass after it.

Validation on Windows / Node 24.19.0:

  • pnpm exec vitest run packages/core/src --exclude '**/repeat-schema-parity.test.ts': 545 tests passed.
  • pnpm --filter @json-render/core build: passed, including declaration generation.
  • Full core tests, tsc and pnpm type-check were attempted but couldn't complete with the core-only dependency install: the cross-renderer parity test needs other workspace packages, and the workspace check stops on missing Next.js dependencies in example-gsplat.

No browser UI test was run.

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

@ROTl24 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Escape tilde and slash characters in each object key before appending it to the JSON Pointer prefix. This prevents literal slash-containing keys from colliding with nested paths and lets state-store reads and writes resolve tilde-containing keys correctly. Preserve existing prefixes and document the escaping behavior in the core README and skill.

Add regression coverage for path collisions, nested escaping with an existing prefix, and state-store read/write round trips. All three tests fail before the fix and pass after it. The 545 standalone core tests and the core build, including declaration generation, pass. Full core tests, tsc, and workspace type-check remain blocked by missing cross-workspace dependencies in the selective install. Browser UI behavior was not tested.
@ROTl24
ROTl24 force-pushed the fix/flatten-json-pointer-keys branch from c45c749 to 80ca66a Compare September 19, 2026 15:07

This branch has not been deployed

No deployments
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.

1 participant