Skip to content

Report a nonexistent decode input the same way every other command does - #862

Merged
jviotti merged 1 commit into
sourcemeta:mainfrom
magic-peach:fix/decode-enoent-reporting
Sep 14, 2026
Merged

jviotti merged 1 commit into
sourcemeta:mainfrom
magic-peach:fix/decode-enoent-reporting

Conversation

@magic-peach

@magic-peach magic-peach commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

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.

Review in cubic

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@augmentcode

augmentcode Bot commented Sep 14, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR standardizes decode input-file handling with the rest of the CLI.

Changes:

  • Replaces manual binary `ifstream` opening and assertions with `sourcemeta::core::read_file`.
  • Routes nonexistent decode inputs through the shared `IOFileNotFoundError` handling path instead of aborting when assertions are enabled.
  • Adds plain-text and `--json` CLI regression coverage for a missing `.binpack` input.
  • Registers the new decode failure test in the CMake test suite.

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 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@jviotti jviotti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@jviotti
jviotti merged commit 7f3decb into sourcemeta:main Sep 14, 2026
16 checks passed
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