docs(mctx): say why the MINIMAL_INDEX_SOURCE match arms differ - #1134
Merged
Conversation
Both arms of the `map_err` added in #1132 produce `Error::Other(anyhow!(...))` and read as interchangeable. They are not. `rcache::Error`'s Display is `write!(f, "{:?}", self)` — it Debug-formats itself — so the fallback arm renders a Config as `Config("MINIMAL_INDEX_SOURCE: unknown index source \"banana\" ...")`, variant name and escaped quotes included. That is exactly the string gominimal/inbox#447 was filed about. Destructuring Config and formatting the inner `msg` is what produces the clean user-facing message. Collapsing this to a single arm would reintroduce the defect while looking like a simplification. Found while reviewing #1132, where I nearly filed that simplification myself before checking the Display impl. Comment only; no behaviour change. `cargo check -p mctx --locked` and `cargo fmt --all --check` both clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
evanspearman
approved these changes
Jul 31, 2026
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.
Comment-only follow-up to #1132. No behaviour change.
The trap
Both arms of the
map_errproduceError::Other(anyhow!(...))and read as interchangeable:They are not.
rcache::Error's Display is:It Debug-formats itself, so the fallback arm renders a
ConfigasConfig("MINIMAL_INDEX_SOURCE: unknown index source \"banana\" ...")— variant name and escaped quotes included. That is precisely the string gominimal/inbox#447 was filed about. DestructuringConfigand formatting the innermsgis what yields the clean user-facing message.Collapsing this to a single arm would reintroduce the defect while looking like a simplification.
Why it's worth a comment
I found this reviewing #1132 and my first instinct was to file exactly that simplification. I only caught it by going and reading the
Displayimpl in another crate. The next reader will have the same instinct with less reason to check.Verification
cargo check -p mctx --locked— cleancargo fmt --all -- --check— clean🤖 Generated with Claude Code
Note
Document why
MINIMAL_INDEX_SOURCEmatch arms inContext.download_if_availabledifferAdds an inline comment in lib.rs explaining that the two
map_errarms forRemoteError::Configare not interchangeable: one formats viaDisplay(which produces Debug output), the other destructures to extract a clean inner message for user-facing output.Macroscope summarized 71d6673.