fix: report output file write failures cleanly#1038
Open
He-Pin wants to merge 1 commit into
Open
Conversation
4b622f2 to
244001d
Compare
Motivation: Some --output-file write failures, including multi-mode file-list writes, could bypass the existing write wrapper and surface raw Java exception details. Modification: Route normal output-file writes, byte/YAML output streams, and multi-mode file-list writes through handleWriteFile. Include the user path in errors and normalize missing, malformed, and IO path failures. Add JVM CLI regression tests for missing parents, malformed output paths, and multi-mode output-file failures. Result: Output-file write failures now return exit code 1 with concise diagnostics instead of stack traces or raw path exception classes.
e88687d to
5bc45e8
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.
Motivation
Output-file creation failures could leak raw Java exceptions instead of clean CLI diagnostics. The original
handleWriteFile[T](f: => T)also interpolated the by-name write expression while formatting errors, which could re-evaluate a failing write path.NoSuchFileExceptionstack traceopen path/out.json: no such file or directoryopen <path>: <message>--multi --output-filefile-list write failureModification
handleWriteFileto take an eagerpath: Stringlabel and a by-name write thunk separately.handleWriteFile.Result
Verification
./mill --no-daemon 'sjsonnet.jvm[3.3.8].test' sjsonnet.MainTests./mill --no-daemon 'sjsonnet.jvm[3.3.8].checkFormat'