Skip to content

fix: process all documents from stdin, not just the first - #49

Merged
MPV merged 1 commit into
masterfrom
claude/stdin-multidoc
Aug 8, 2026
Merged

fix: process all documents from stdin, not just the first#49
MPV merged 1 commit into
masterfrom
claude/stdin-multidoc

Conversation

@MPV

@MPV MPV commented Jul 23, 2026

Copy link
Copy Markdown
Owner

What

Route the stdin path through the same document-splitting the file path already uses, so a multi-document stream piped into kir - yields images from every document, not just the first.

Before → After

Given a two-document manifest on stdin (a Deployment, then a CronJob):

$ kir - < deploy-and-cronjob.yaml   # or: kubectl get deploy,cronjob -o yaml | kir -

# before
nginx:1.27
# ^ only the first document is read; backup:2.1 from the CronJob is silently dropped

# after
nginx:1.27
backup:2.1

Exit code is 0 in both cases — the failure was silent, which is what made it dangerous.

Why

ProcessStdin handed the whole stdin buffer to yamlparser.ProcessData, whose decoder reads only the first YAML document. Files already went through a splitting path, so kir file.yaml handled multiple documents correctly while … | kir - did not — the same input via two routes gave different results. Stdin now goes through the shared processDocuments path, so both routes behave identically.

Tests

Adds a TestCLI/StdinMultiDoc golden that pipes a two-document stream through cmd.Run — the seam where the bug lived. The pre-existing TestCLI/Stdin case pipes a single document, so it passed with or without this fix; the new golden emits both images only with the fix (verified: it fails on master, printing just nginx:1.27).

Release

fix: → patch. This is silent data loss in an existing path (stdin already worked; it just truncated), not a new capability — contrast #54, which makes the tool tolerate input it previously rejected outright.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC

@MPV
MPV changed the base branch from master to claude/approve-stdout-stderr July 23, 2026 07:09
@MPV
MPV force-pushed the claude/stdin-multidoc branch from 7e2273e to 8f215aa Compare July 23, 2026 07:10
@MPV
MPV force-pushed the claude/stdin-multidoc branch 2 times, most recently from 8696395 to 6e5fb8d Compare July 23, 2026 08:24
Base automatically changed from claude/approve-stdout-stderr to master July 24, 2026 06:40
@MPV
MPV force-pushed the claude/stdin-multidoc branch from 6e5fb8d to c2e30c5 Compare July 24, 2026 06:45
@MPV
MPV force-pushed the claude/stdin-multidoc branch 3 times, most recently from c24a2fe to 177ed18 Compare August 6, 2026 20:57
@MPV MPV changed the title Process all documents from stdin, not just the first fix: process all documents from stdin, not just the first Aug 6, 2026
@MPV
MPV force-pushed the claude/stdin-multidoc branch from 177ed18 to bf1dff2 Compare August 6, 2026 21:52
@MPV
MPV force-pushed the claude/stdin-multidoc branch 2 times, most recently from 0a09dd0 to fedfc38 Compare August 8, 2026 22:05
ProcessStdin passed the whole stdin buffer to yamlparser.ProcessData,
whose decoder only reads the first YAML document, so a multi-document
stream piped in (e.g. `kubectl get ... -o yaml | kir -`) silently dropped
every document after the first.

Route stdin through the same document-splitting path already used for
files (extracted as processDocuments) so both handle multi-document input
identically.

Cover it end-to-end with a TestCLI/StdinMultiDoc golden: the existing
Stdin case pipes a single document, so it passed with or without the fix;
the new two-document fixture fails through cmd.Run without it (only the
first image is emitted) and pins the fixed behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
@MPV
MPV force-pushed the claude/stdin-multidoc branch from fedfc38 to dc8fda7 Compare August 8, 2026 22:19
@MPV
MPV merged commit 4e36f41 into master Aug 8, 2026
1 check passed
@MPV
MPV deleted the claude/stdin-multidoc branch August 8, 2026 22:21
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.

2 participants