zon-TS icon indicating copy to clipboard operation
zon-TS copied to clipboard

Port round-trip bug fixes from Python ZON PR#9 to TypeScript

Open Copilot opened this issue 7 months ago • 3 comments

  • [x] Confirm top-level objects bypass _formatZonNode/_parseKey code paths
  • [x] Update boolean-keys.test.ts: wrap fixtures in { wrapper: {...} } so tests exercise the patched code paths
  • [x] Replaced broken mixed-key array test with a multi-sibling-object test
  • [x] All 311 tests pass

Copilot avatar Apr 23 '26 20:04 Copilot

@coderabbitai look into this PR

ronibhakta1 avatar Apr 27 '26 21:04 ronibhakta1

@ronibhakta1 Sure! I'll start reviewing this PR now. I'll look into the three round-trip bug fixes ported from the Python ZON implementation — boolean-like dictionary keys, dictionary header value quoting, and the associated test coverage. I'll post my findings shortly.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Apr 27 '26 21:04 coderabbitai[bot]

📝 Walkthrough

Walkthrough

This 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 parseKey utility function distinguishes key parsing from value parsing, with updates to encoder and decoder accordingly.

Changes

Cohort / File(s) Summary
Test Coverage
src/__tests__/boolean-keys.test.ts, src/__tests__/dict-header-quoting.test.ts
New Jest test suites validating encoding/decoding of boolean-like dictionary keys ("true", "false", "null", etc.) and dictionary headers containing commas and colons, ensuring round-trip preservation of original string keys and field values.
Key Parsing Utility
src/core/utils.ts
Introduces parseKey function for ZON dictionary keys that always returns strings, supporting double-quoted and single-quoted keys, with ZON-to-JSON escape sequence conversion, without boolean/null keyword conversion.
Decoder Key Handling
src/core/decoder.ts
Updates key parsing to use _parseKey instead of _parseValue, and enhances dictionary handling by splitting and parsing dictionary values with awareness of quotes and nesting.
Encoder Key Quoting
src/core/encoder.ts
Adds quoting of object keys that resemble boolean/null keywords (true/false/t/f/null/none/nil, case-insensitive) to prevent misinterpretation; formats dictionary string values via _formatValue before emission.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Keys and values, quite the pair! We parse them with the utmost care. No more "true" masquerading as a fact, Each quoted key stays on its track. Boolean-like keys now round-trip true, The ZON encoder/decoder's breakthrough! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective of the PR: porting round-trip bug fixes from the Python ZON implementation to TypeScript, which aligns with the substantial changes across encoder, decoder, and utilities.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • [ ] Create stacked PR
  • [ ] Commit on current branch
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Commit unit tests in branch copilot/sync-with-other-package

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Apr 27 '26 21:04 coderabbitai[bot]