Port round-trip bug fixes from Python ZON PR#9 to TypeScript#3
Conversation
Agent-Logs-Url: https://github.com/ZON-Format/zon-TS/sessions/e5aab0b1-0f14-4a0f-bb3d-279a7a7bf62b Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
- Fix 1 (encoder): Quote boolean/null keyword keys (t, f, true, false,
null, none, nil) in _formatZonNode to prevent round-trip corruption
- Fix 2 (decoder): Add parseKey() that always preserves keys as strings,
replacing parseValue() at all key-parsing call sites
- Fix 3 (encoder): Quote dictionary header values that contain commas or
other special characters using _formatValue()
- Fix 4 (decoder): Use _splitByDelimiter() + _parseValue() for dictionary
header value parsing instead of naive vals.split(',')
- Add tests: boolean-keys.test.ts and dict-header-quoting.test.ts
Agent-Logs-Url: https://github.com/ZON-Format/zon-TS/sessions/e5aab0b1-0f14-4a0f-bb3d-279a7a7bf62b
Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
|
@coderabbitai look into this PR |
|
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis PR adds test coverage and implementation improvements for ZON encoding/decoding edge cases, including boolean-like dictionary keys and special characters in headers. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/__tests__/boolean-keys.test.ts (1)
12-98: Broaden these cases to hit the new parser path.The top-level scalar fixtures still serialize through metadata lines, so they won't fail if
_formatZonNode/_parseKeyregresses. Consider moving the boolean-like keys under an object-valued property, or into an array-of-objects fixture, so these tests actually cover the fix.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/__tests__/boolean-keys.test.ts` around lines 12 - 98, The tests currently encode top-level scalar objects so they bypass the new parser path; change each fixture to place the boolean-like keys inside an object-valued property (e.g. const data = { wrapper: { f: 1 } }) or into an array of objects (e.g. const data = { items: [{ f: 1 }] }) so encode/decode passes through the zone-node formatting/parsing code paths (those exercised by _formatZonNode / _parseKey); update the assertions to inspect decoded.wrapper.f or decoded.items[0].f (and corresponding keys like 'true','false','null') and adjust the case-variant loop and multi-key test similarly so they validate nested/object-array decoded values instead of top-level keys.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/__tests__/boolean-keys.test.ts`:
- Around line 12-98: The tests currently encode top-level scalar objects so they
bypass the new parser path; change each fixture to place the boolean-like keys
inside an object-valued property (e.g. const data = { wrapper: { f: 1 } }) or
into an array of objects (e.g. const data = { items: [{ f: 1 }] }) so
encode/decode passes through the zone-node formatting/parsing code paths (those
exercised by _formatZonNode / _parseKey); update the assertions to inspect
decoded.wrapper.f or decoded.items[0].f (and corresponding keys like
'true','false','null') and adjust the case-variant loop and multi-key test
similarly so they validate nested/object-array decoded values instead of
top-level keys.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 28649438-7a7e-46bc-a7af-8000e6ec5b5c
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
src/__tests__/boolean-keys.test.tssrc/__tests__/dict-header-quoting.test.tssrc/core/decoder.tssrc/core/encoder.tssrc/core/utils.ts
…_formatZonNode/_parseKey paths
Per coderabbitai review: top-level `{ f: 1 }` encoded as implicit KV (f:1)
and bypassed the _formatZonNode / _parseKey code paths. Updated all fixtures
to `{ wrapper: { keyword: 1 } }` so encode produces `wrapper{"keyword":1}`,
going through the patched code. Also replaced a broken array-of-mixed-keys
test with a multi-sibling-object test that encodes via _formatZonNode.
Agent-Logs-Url: https://github.com/ZON-Format/zon-TS/sessions/d685654f-1fcf-4efb-892d-ca37bbc8657e
Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
_formatZonNode/_parseKeycode pathsboolean-keys.test.ts: wrap fixtures in{ wrapper: {...} }so tests exercise the patched code paths