fix: exit non-zero when a file cannot be processed - #55
Merged
Conversation
MPV
force-pushed
the
claude/execute-returns-error
branch
from
July 23, 2026 07:14
dea6982 to
c060823
Compare
MPV
force-pushed
the
claude/execute-returns-error
branch
from
July 23, 2026 08:17
c060823 to
b3973cd
Compare
This was referenced Jul 23, 2026
MPV
force-pushed
the
claude/execute-returns-error
branch
from
July 23, 2026 08:46
b3973cd to
d81dee0
Compare
MPV
force-pushed
the
claude/execute-returns-error
branch
from
July 24, 2026 06:45
d81dee0 to
52bfab2
Compare
MPV
force-pushed
the
claude/nonzero-exit
branch
from
August 2, 2026 07:57
713ab54 to
2e16578
Compare
MPV
force-pushed
the
claude/nonzero-exit
branch
2 times, most recently
from
August 6, 2026 20:57
d0e1a34 to
2d3647e
Compare
MPV
force-pushed
the
claude/nonzero-exit
branch
2 times, most recently
from
August 8, 2026 21:47
53fe0b3 to
ca552c8
Compare
MPV
force-pushed
the
claude/nonzero-exit
branch
3 times, most recently
from
August 9, 2026 13:05
ee7024e to
6d71fe7
Compare
MPV
pushed a commit
that referenced
this pull request
Aug 9, 2026
#55 (exit non-zero on a processing failure) and #57 (error on a no-match argument), now combined here, share one contract: kir processes the whole batch, prints what it can, and exits non-zero if any input failed. Record it as docs/adr/0008-best-effort-processing-and-exit-codes.md and point ADR 0007's exit-column reference at it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
Per-file processing errors were logged but Run still returned 0, so a pipeline like `kir manifests/* | xargs grype` could not tell that some manifests failed to parse — the kind of silent gap that matters for a tool feeding a vulnerability scanner. Count per-file failures and, after processing every file, return a non-zero exit code. Files that succeed are still printed; only the exit status changes. The behavioral golden suite pins this: TestFailure/BadYAML feeds a malformed manifest through cmd.Run and asserts the error on stderr plus exit 1 (without this change it exits 0). TestRunFileFailure covers the same contract at the cmd unit level. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
filepath.Glob returns no matches and no error both for a glob that matches nothing and for a literal path that does not exist, so a typo'd filename was silently skipped: `kir typo.yaml` produced no output and exited 0. Treat an argument that resolves to zero files as an error naming that argument; Run then reports it and exits non-zero. The behavioral golden suite reflects this: TestCLI.MissingFile now exits 1 with the error on stderr. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
#55 (exit non-zero on a processing failure) and #57 (error on a no-match argument), now combined here, share one contract: kir processes the whole batch, prints what it can, and exits non-zero if any input failed. Record it as docs/adr/0008-best-effort-processing-and-exit-codes.md and point ADR 0007's exit-column reference at it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
MPV
force-pushed
the
claude/nonzero-exit
branch
from
August 9, 2026 20:08
887effa to
4b2374b
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
Make
kirfail loud via the exit code instead of silently reporting success. Two related fixes (the second folded in from #57):Runstill returned0.filepath.Globreturns no matches and no error for both an empty glob and a missing literal path, so a typo was silently skipped.Before → After
Successes are still printed either way —
kiris best-effort and never aborts the batch on one bad input; only the exit status changes.Why
For a tool feeding a scanner (
kir manifests/* | xargs grype), a zero exit must mean every input was understood. A parse failure or a mistyped path silently exiting 0 is the dangerous gap.Tests
TestFailure/BadYAML(approval): malformed manifest throughcmd.Run→ error on stderr + exit 1 (exits 0 without this change).TestCLI.MissingFile(approval): no-match argument → error + exit 1.cmd_test.goTestRunFileFailureandfileutilunit tests cover the same at their layers.Docs
Records the contract as
docs/adr/0008-best-effort-processing-and-exit-codes.md(best-effort; failures surface via the exit code) and points ADR 0007's exit-column reference at it.Release
Based on
master.fix:→ patch. (Combines the former #55 + #57, which is merged into this branch.)🤖 Generated with Claude Code
https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC