Report a nonexistent decode input the same way every other command does - #862
Merged
Merged
Conversation
Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
🤖 Augment PR SummarySummary: This PR standardizes Changes:
Technical Notes: The shared helper preserves binary stream semantics and reports canonical file-path diagnostics consistently with other commands. 🤖 Was this summary useful? React with 👍 or 👎 |
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.
The decode command opened its input file with a raw std::ifstream guarded only by assert(!input_stream.fail()), the only command in the CLI still doing this instead of the shared read_file helper every other command (encode and 7 others) already uses.
In a build where assertions are compiled in, a nonexistent .binpack path crashes the process outright: Assertion failed: (!input_stream.fail()), function decode, file command_decode.cc, line 61, exit code 134. Confirmed this directly by reverting just the fix and running decode against a missing file.
This switches to read_file, which routes through the same IOFileNotFoundError handling every other command already relies on, turning the crash into the standard error: No such file or directory that decode, validate, and the rest of the CLI already give for this class of error.
Verified by adding test/decode/fail_enoent.clitest, matching the existing test/validate/fail_schema_enoent.clitest convention, and running the full test suite locally: 1136 tests, all passing.