chore(usage): escape the raw NUL bytes in jsonl-parser.ts as \0 - #84
Merged
Conversation
The file held 4 raw NUL bytes: 2 are the Map-key separators in template literals (offsets 7260, 7365) and 2 sit in the comment describing them (5708, 5745). Git classifies a blob binary when it finds a NUL in the first 8000 bytes, so it was the COMMENT's NUL that tripped the check and suppressed the file's diff entirely -- including from the repo's own audit greps, which then returned 0 matches as a false negative. `\0` in a TypeScript template literal produces the same U+0000 character, so this is a source-encoding change with no runtime effect. Verified by undoing the escape and comparing: it reproduces the previous blob byte-for-byte. Split out as its own commit deliberately. GitHub sniffs the PRE-image when deciding binary-vs-text and does not apply the head tree's .gitattributes -- measured on an earlier revision of this branch, where the commits API reported no patch for this file even though .gitattributes was present in the same tree. Landing the escape separately gives the following commit a NUL-free pre-image, which is what GitHub actually looks at. This commit's own diff still renders as binary. It is 4 bytes; `git show <sha> -- src/usage/jsonl-parser.ts` or the round-trip check above settles it.
7 tasks
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.
Mechanical prerequisite for #83, landed separately on purpose.
src/usage/jsonl-parser.tsholds 4 raw NUL bytes: 2 are theMap-keyseparators in template literals (offsets 7260, 7365) and 2 sit in the comment
describing them (5708, 5745). Git classifies a blob binary when it finds a NUL
in the first 8000 bytes, so it was the comment's NUL that tripped the check
and suppressed this file's diff entirely — including from the repo's own audit
greps in
coding-style.md, which then return 0 matches as a false negative.\0in a TypeScript template literal produces the same U+0000 character, sothis is a source-encoding change with no runtime effect. Verified by undoing
the escape and comparing: it reproduces the previous blob byte-for-byte
(8052 bytes, 4 NUL → 8056 bytes, 0 NUL, delta exactly 4).
Why this is its own PR
GitHub decides binary-vs-text by sniffing the pre-image and ignores the head
tree's
.gitattributes— measured on #83, where the commits API reported nopatch for this file even though
.gitattributessat in the same tree. Splittingthe escape into its own commit on the same branch fixed the per-commit view but
not the PR-level "Files changed" tab, which still diffs against
main.Landing the escape on
mainfirst is what makes #83's diff reviewable in thenormal view.
Note on the diff
This PR's own diff renders as "Binary files differ" — unavoidable, since its
pre-image is the NUL-bearing blob. It is 4 bytes. To verify:
(identical with NULs stripped from both sides = nothing but the escapes changed)
Test plan
bun testat this commit — 180 pass / 0 failorigin/main's blob exactly