Skip to content

fix: error on file arguments that match nothing - #57

Merged
MPV merged 1 commit into
claude/nonzero-exitfrom
claude/error-missing-files
Aug 9, 2026
Merged

fix: error on file arguments that match nothing#57
MPV merged 1 commit into
claude/nonzero-exitfrom
claude/error-missing-files

Conversation

@MPV

@MPV MPV commented Jul 23, 2026

Copy link
Copy Markdown
Owner

What

Treat a file argument that resolves to zero files as an error naming that argument.

Before → After

$ kir typo.yaml; echo "exit=$?"

# before
exit=0                                        # silently ignored, no output

# after
error: no such file or match for "typo.yaml"
exit=1

Why

filepath.Glob returns no matches and no error both for a glob that matches nothing and for a literal path that doesn't exist — so a typo was silently skipped. Now it errors, and Run reports it and exits non-zero.

Golden suite: TestCLI.MissingFile now exits 1 with the error on stderr.

Stack / Release

Top of the CLI stack (#55 → this). fix: → patch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC

@MPV
MPV force-pushed the claude/error-missing-files branch from cf28833 to f47ab43 Compare July 23, 2026 07:14
@MPV
MPV force-pushed the claude/nonzero-exit branch from 10cad80 to 2163e29 Compare July 23, 2026 08:18
@MPV
MPV force-pushed the claude/error-missing-files branch from 10f5d17 to 33cead9 Compare July 23, 2026 08:24
@MPV
MPV force-pushed the claude/error-missing-files branch from f47ab43 to 10f5d17 Compare July 23, 2026 08:45
@MPV
MPV force-pushed the claude/nonzero-exit branch from 33e1541 to 713ab54 Compare July 24, 2026 06:45
@MPV
MPV force-pushed the claude/error-missing-files branch from 33cead9 to 64ff278 Compare July 24, 2026 06:45
@MPV
MPV force-pushed the claude/nonzero-exit branch from 713ab54 to 2e16578 Compare August 2, 2026 07:57
@MPV
MPV force-pushed the claude/error-missing-files branch from 64ff278 to 9bb2ee4 Compare August 2, 2026 07:58
@MPV
MPV force-pushed the claude/nonzero-exit branch from 2e16578 to d0e1a34 Compare August 6, 2026 20:55
@MPV
MPV force-pushed the claude/error-missing-files branch from 9bb2ee4 to e54ca21 Compare August 6, 2026 20:57
@MPV
MPV force-pushed the claude/nonzero-exit branch from d0e1a34 to 2d3647e Compare August 6, 2026 20:57
@MPV
MPV force-pushed the claude/error-missing-files branch from e54ca21 to 3f146ce Compare August 6, 2026 21:06
@MPV MPV changed the title Error on file arguments that match nothing fix: error on file arguments that match nothing Aug 6, 2026
@MPV
MPV force-pushed the claude/nonzero-exit branch from 2d3647e to 53fe0b3 Compare August 6, 2026 21:52
@MPV
MPV force-pushed the claude/error-missing-files branch from 3f146ce to 9fe9c10 Compare August 6, 2026 21:52
@MPV
MPV force-pushed the claude/nonzero-exit branch from 53fe0b3 to ca552c8 Compare August 8, 2026 21:47
@MPV
MPV force-pushed the claude/error-missing-files branch from 9fe9c10 to 0695b9c Compare August 8, 2026 21:47
@MPV
MPV force-pushed the claude/nonzero-exit branch from ca552c8 to 87da9bd Compare August 9, 2026 12:55
@MPV
MPV force-pushed the claude/error-missing-files branch from 0695b9c to 46823aa Compare August 9, 2026 12:55
@MPV
MPV force-pushed the claude/nonzero-exit branch from 87da9bd to ee7024e Compare August 9, 2026 12:59
@MPV
MPV force-pushed the claude/error-missing-files branch from 46823aa to 41ce0c9 Compare August 9, 2026 12:59
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
@MPV
MPV force-pushed the claude/nonzero-exit branch from ee7024e to 6d71fe7 Compare August 9, 2026 13:05
@MPV
MPV force-pushed the claude/error-missing-files branch from 41ce0c9 to 29869fa Compare August 9, 2026 13:05
@MPV
MPV merged commit bb626ae into claude/nonzero-exit Aug 9, 2026
@MPV
MPV deleted the claude/error-missing-files branch August 9, 2026 13:06
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
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
MPV added a commit that referenced this pull request Aug 9, 2026
* fix: exit non-zero when a file cannot be processed

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

* fix: error on file arguments that match nothing

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

* docs: record best-effort processing and exit codes as ADR 0008

#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

---------

Co-authored-by: Claude <noreply@anthropic.com>
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