Skip to content

fix: remove doubled prefixes from min CLI error output - #1151

Merged
norrietaylor merged 1 commit into
mainfrom
inbox-patch/fix-doubled-error-prefixes-8fab2189aa68bcd2
Aug 1, 2026
Merged

fix: remove doubled prefixes from min CLI error output#1151
norrietaylor merged 1 commit into
mainfrom
inbox-patch/fix-doubled-error-prefixes-8fab2189aa68bcd2

Conversation

@gominimal-aw-bot

@gominimal-aw-bot gominimal-aw-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKmgvEQ

Two min error paths printed the same text twice. min session activate --loadout <missing> repeated the OS-error string because
resolve_active_loadouts layered anyhow context over a LoadError
whose Display already embeds its I/O source. min update outside a
project printed minimal.toml: minimal.toml not found because both the
mctx boundary and mfile's NotFound led with the filename. The fixes
flatten the loadout error to a leaf and make NotFound context-free,
upholding the thiserror/anyhow boundary (informed by ADR-0001); each
path gains a regression test.

Verification

cargo fmt --all --check --manifest-path target/Cargo.toml — clean
cargo clippy --workspace --locked -- -D warnings — 0 warnings
cargo build --workspace --locked — ok
cargo test --workspace --locked — ok (all suites green; +2 new tests)

Note

Fix doubled prefixes in min CLI error output for missing files and loadouts

  • Removes the filename prefix from mfile::Error::NotFound's Display impl so it renders as "not found" instead of "minimal.toml: not found", preventing duplication when the caller adds context.
  • Flattens the anyhow error chain in resolve_active_loadouts so I/O errors from missing loadout files appear exactly once alongside the --loadout \name`` context string.
  • Adds unit tests in both crates to assert the error strings are not doubled.

Macroscope summarized 91f9a78.

Two error-formatting sites in the min CLI rendered the same text
twice in the displayed error chain.

In the loadout path, resolve_active_loadouts wraps read_loadout_file's
LoadError with anyhow context. That LoadError's Display already embeds
its I/O source, so anyhow also walked into the source and printed the
OS error a second time. Flatten the LoadError to a leaf before adding
context.

In the update path, mctx's MFile Display prepends "minimal.toml: "
while mfile's NotFound Display also led with the filename, producing
"minimal.toml: minimal.toml not found". Make NotFound context-free so
the boundary supplies the filename exactly once.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 26035c0b-2490-437a-8437-349ea7c26584

📥 Commits

Reviewing files that changed from the base of the PR and between 4a738d4 and 91f9a78.

📒 Files selected for processing (3)
  • crates/mctx/src/error.rs
  • crates/mfile/src/error.rs
  • crates/minimal/src/loadouts.rs

Comment @coderabbitai help to get the list of available commands.

@norrietaylor

Copy link
Copy Markdown
Member

Reviewed — the shared-type change is safe, and it improves an existing message

The risky part of this diff is changing mfile::Error::NotFound's Display from "{MFILE_NAME} not found" to bare "not found". That is a shared error type, so any caller rendering it standalone would lose the filename and print an unhelpful bare not found.

I checked every consumer. All of them pattern-match the variant and construct their own message — decode/src/lib.rs:145, mctx/src/project_setup.rs:36, mfile/src/lib.rs:802/809/814, minimal/src/lib.rs:1423/1492, minimal/src/task.rs:96, minimald/src/session.rs:1451, minimald/src/sessions/composables.rs:265. None relies on the old Display text.

The one place that does render it is minimal/src/lib.rs:2846 — the min init hint added in #1140, which formats "{e}\nRun 'min init'...". That path goes through mctx::Error::MFile, whose Display supplies the filename, so it now reads:

minimal.toml: not found
Run 'min init' to give the project its own config.

Before this change it produced minimal.toml: minimal.toml not found — the exact doubling this PR exists to fix. So #1140's hint gets better, not worse.

The map_err(|e| anyhow::anyhow!("{e}")) flatten in resolve_active_loadouts is the right shape too: LoadError's Display already embeds its I/O source, so collapsing it to a leaf before .with_context is what stops anyhow re-rendering the chain. Both regression tests assert the single-prefix form directly rather than asserting on a substring, which is what makes them worth having.

@norrietaylor
norrietaylor marked this pull request as ready for review July 31, 2026 22:41
@norrietaylor
norrietaylor requested a review from a team as a code owner July 31, 2026 22:41
@norrietaylor
norrietaylor merged commit d0e84db into main Aug 1, 2026
30 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/fix-doubled-error-prefixes-8fab2189aa68bcd2 branch August 1, 2026 00:20
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.

1 participant