Repository navigation
fix: preserve empty-string parents in JSON roundtrips - #247
Merged
rustedgrail merged 2 commits intoOct 23, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An empty string is a node ID accepted by the Graph API, but JSON restoration silently drops it when it is used as a parent:
The serialized object contains
parent: '', butjson.readtreats it as an absent parent. This moves the child to the root instead of restoring the original hierarchy.Change
Test the optional parent field against
undefined, matchingjson.writeandGraph.setParent, rather than testing its truthiness. Add a regression covering the parent, its children and the root children after a stringify/parse roundtrip. No graph API or serialization format change.Validation
d649cb32a827619da09959c89d8973aaf2370b4eand passes with this change.npm ci,npm run lint,npm run build,npm run typecheck: pass.npm test -- --runInBand: 258/259 tests pass (19/20 suites). The unchangeddist-exports.test.tsESM smoke test fails on Windows because it imports a rawD:path rather than afile:URL (ERR_UNSUPPORTED_ESM_URL_SCHEME). This is separate from JSON restoration.Local environment: Windows, Node 24.14.1, TypeScript 5.9.3.
makeis unavailable; the npm commands used by its build/test/lint targets were run directly. Linux/Node 18 CI has not been run locally. Generated bundles were rebuilt for validation; only canonical source and the regression test are committed, following the existing source-fix/release-build convention.