Skip to content

A mapping ends with the text it has, not at a supplied null - #20

Merged
reuvenharrison merged 1 commit into
v3from
fix/explicit-key-null-end
Oct 26, 2026
Merged

reuvenharrison merged 1 commit into
v3from
fix/explicit-key-null-end

Conversation

@reuvenharrison

Copy link
Copy Markdown
Collaborator

An explicit key with no value gets a null that the parser supplies, marked at the start of the line after the key. A mapping takes its end from its last child, so a mapping ending in such a key reached past its own text:

input mapping end, before after lines of text
? 00 2:1 1:5 1
a:\n? b 3:1 2:4 2

The first row is the one that matters: the end is past the end of the document, so a consumer reconstructing the block span from __origin__ gets a line that does not exist.

The fix ends the mapping at the last child the document actually wrote. A value that is merely empty rather than absent sits on the key's own line, so a: still ends at 1:3 as before, and sequences are untouched (a valueless - gets its null on the dash's own line, which is already in bounds).

Found by fuzzing kin-openapi's loader, whose origins target requires every recorded position to lie inside the input. That fuzz target has been failing on ? 00 on kin's master since yesterday.

Tests: a case in end_position_test.go covering the absent-value and empty-value forms. Full suite passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_017e285CvofYf6joqC98gTXz

An explicit key with no value gets a null the parser supplies for it,
marked at the start of the line after the key. A mapping takes its end
from its last child, so one ending in such a key reached a line past its
own text, and past the whole document when the key was on the last line:
`? 00` reported the mapping ending on line 2 of a one-line document, and
`a:\n? b` on line 3 of a two-line one.

End with the last child that the document actually wrote. A value that
is merely empty rather than absent sits on the key's own line and still
ends the entry, so `a:` is unchanged.

Found by fuzzing kin-openapi's loader, where the recorded origin has to
lie inside the input.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017e285CvofYf6joqC98gTXz
@reuvenharrison
reuvenharrison merged commit 5046ba4 into v3 Oct 26, 2026
4 checks passed
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