fix: split YAML documents with the Kubernetes YAML reader - #56
Merged
Conversation
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
July 23, 2026 07:09
9941ad2 to
1fb8717
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
2 times, most recently
from
July 23, 2026 08:24
7d70b66 to
dd5529b
Compare
This was referenced Jul 23, 2026
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
July 24, 2026 06:45
dd5529b to
324f980
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 2, 2026 08:01
324f980 to
129d31d
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 6, 2026 21:06
129d31d to
986d4be
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 6, 2026 21:52
986d4be to
d33fb0d
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 8, 2026 21:47
d33fb0d to
d4aabb8
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 8, 2026 22:05
d4aabb8 to
b88998a
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 8, 2026 22:19
b88998a to
346897e
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 8, 2026 22:21
346897e to
87b97ff
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
2 times, most recently
from
August 8, 2026 22:58
d961e96 to
f90c1f0
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 8, 2026 23:02
f90c1f0 to
dfc4134
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 9, 2026 12:55
dfc4134 to
22dd423
Compare
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
3 times, most recently
from
August 9, 2026 20:14
937ea8c to
00b8d06
Compare
Document splitting used bytes.Split on the literal "\n---\n", which drops
every document after the first when the separator isn't exactly that: a
separator with trailing whitespace ("--- ") or CRLF line endings both
glue the documents together.
Before (two Pods separated by "---" with trailing spaces):
$ kir pods.yaml
img-a:1
# img-b:2 from the second document is silently dropped
After:
$ kir pods.yaml
img-a:1
img-b:2
Replace it with apimachinery's YAMLReader via a new yamlparser.ProcessReader
that streams documents from an io.Reader. Both the file and stdin paths read
through it, so their splitting behaves identically and matches how Kubernetes
itself parses manifests.
Returning ProcessData's error directly also drops the redundant
"error processing document:" wrapper (e.g. malformed YAML now reads
"error: <cause>" instead of "error: error processing document: <cause>"); the
TestFailure/BadYAML golden is updated to match.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
MPV
force-pushed
the
claude/robust-yaml-splitting
branch
from
August 9, 2026 20:15
00b8d06 to
dae5df2
Compare
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.
What
Split YAML documents with apimachinery's
YAMLReader(via a new streamingyamlparser.ProcessReader) instead ofbytes.Spliton the literal"\n---\n".Before → After
A two-document manifest whose separator has trailing whitespace —
---followed by spaces, common in hand-edited and templated YAML:Verified against
master. CRLF (\r\n) line endings are the other real case —bytes.Splitmisses that separator too and drops everything after the first document. (Leading---and a missing final newline are not affected; they're kept in the unit test only as general correctness checks.)Why
bytes.Spliton the literal separator is fragile: any variation glues documents together so every one after the first is lost. Both the file and stdin paths now stream through oneProcessReader, so their splitting behaves identically and matches how Kubernetes itself parses manifests.Note on error text
Returning
ProcessData's error directly also drops the redundanterror processing document:wrapper, so a genuine parse failure now readserror: <cause>instead oferror: error processing document: <cause>.Release
Based on
master.fix:→ patch.🤖 Generated with Claude Code
https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC