fix: respect gitignore in marker walk, classify MCP errors by fault - #485
Merged
Merged
Conversation
Reorder WalkBuilder calls so standard_filters(false) runs before the individual overrides, instead of after — it was silently resetting git_ignore(true) back to false, letting the project-marker search descend into gitignored directories. Add an exhaustive Error::mcp_error_kind() classification and route map_bridge_error and the resource handlers through it. Caller-fault variants now map to invalid_params instead of the generic internal_error catch-all; ServerInitializing and WorkspaceServersInitializing get a retryable code with structured data, matching the existing WorkspaceIndexing pattern; NoWorkspaceRoots and DocumentLimitExceeded stay internal since neither is fixable by changing the request. Closes #476 Closes #479
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.
Summary
LspServerConfig::find_any_marker_recursivecalledWalkBuilder::standard_filters(false)aftergit_ignore(true), silently negating it (last write wins) and letting the project-marker search descend into gitignored directories. Reordered sostandard_filters(false)runs first.map_bridge_errorrouted nearly everycrate::error::Errorvariant through the generic-32603 INTERNAL_ERROR, including clear caller-fault variants, while the resource handlers independently reimplemented correct-32602 INVALID_PARAMSclassification for a subset of cases. Added an exhaustiveError::mcp_error_kind()classification (no wildcard arm) and routed bothmap_bridge_errorand the resource handlers through it, removing the duplicated.map_err(...)chains.Classification notes (from review)
invalid_params, -32602):InvalidToolParams,PathOutsideWorkspace,NotARegularFile,InvalidUri,DocumentNotFound,FileSizeLimitExceeded, andFileIowhen caused by a nonexistent path (ErrorKind::NotFound).data):WorkspaceIndexing(existing, -32050),ServerInitializingandWorkspaceServersInitializing(new, -32051) — both represent "expected LSP server hasn't registered yet."NoWorkspaceRoots(workspace roots are a startup-fixed snapshot — an empty set never fills, no retry helps) andDocumentLimitExceeded(aggregate tracker state, not a bad property of the specific request — the identical request can succeed later once other documents close).Test plan
cargo +nightly fmt --all -- --checkcargo clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --workspace --all-features --lib --bins(973 passed)RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurescargo test --doc(28 passed)Errorvariant, including through theread_resource/subscribehandler chainCloses #476
Closes #479