Repository navigation
Exit 1 for an output folder that can't be created instead of crashing [patch] - #148
Merged
Merged
Conversation
… [patch] Validate only rejects an --output that is itself an existing file, so an output under a file, one the user may not create, or an input folder that can't be listed reached Directory.CreateDirectory / GetFiles outside the per-file catch and ended the run with a stack trace and exit 134. Run now delegates to a testable Execute, which reports those IO and permission failures as an argument error and returns ExitInvalidArguments. Fixes #125 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017kCSwub3LRUKDprfUt2KQ1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017kCSwub3LRUKDprfUt2KQ1
SonarCloud's new-code coverage gate counted Run's untestable Exit branch and Execute's unexercised validation failure path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017kCSwub3LRUKDprfUt2KQ1
|
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.



Fixes #125
What was wrong
Arguments.TryResolveOutputrejects an--outputonly when it names an existing file.ProcessDirectorythen callsDirectory.CreateDirectoryandDirectory.GetFilesbefore its per-file try/catch, andRunhas no handler. So an output folder under a file, an output folder the user isn't allowed to create, or an input folder that can't be listed ended the run with an unhandled exception and exit 134, not the documented exit 1.Change
Runis now a thinEnvironment.Exitwrapper around a newinternal static int Execute(Arguments).Executevalidates, runs the batch, prints the summary and returns the exit code, so a whole run is testable without spawning a process.ExecutecatchesIOExceptionandUnauthorizedAccessExceptionfromProcessDirectory, prints one line in the existingArgument validation failed:format with the exception's message (which names the path), and returnsExitInvalidArguments. Only the two up-front calls can raise these, because each file's own failures are already caught and counted inside the batch. A failure on one file still gives exit 2.CLAUDE.md's exit-codes section describesExecuteand the new catch.Tests
AnOutputFolderUnderAFileExitsWithInvalidArgumentsInsteadOfThrowingcovers the issue's portable case,-o <file>/sub, and needs no permissions setup. With the catch removed it fails (theDirectoryNotFoundExceptionescapes); with the catch it passes.ExecuteReportsSuccessForAGoodRuncovers the new entry point on the happy path./proc/...) and the unlistable-input case need OS-specific permissions, so they have no test. They go through the same catch.GoldMasterTests.OutputMatchesTheGoldMaster, and they fail the same way on unchangedmainin this environment, because the gold-master PNGs are Git LFS pointers and the clone has no LFS content. CI checks out LFS.Generated by Claude Code