Skip to content

fix(mcpls-core): correct error classification and unsubscribe leak - #501

Merged
bug-ops merged 2 commits into
mainfrom
fix/496-499-error-classification
Sep 21, 2026
Merged

bug-ops merged 2 commits into
mainfrom
fix/496-499-error-classification

Conversation

@bug-ops

@bug-ops bug-ops commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Route SubscriptionError::LimitReached through the existing mcp_error_kind classifier instead of hand-mapping it to InvalidParams, matching DocumentLimitExceeded's treatment: it fires on aggregate per-session tracker state, not this request's parameters, so it stays a retryable server-side condition rather than a caller-fault one.
  • Reclassify LspServerError as InvalidParams only for the recognized "position out of range" message shape that sanitize_lsp_server_message already rewrites for display (a stale line/character from the caller). Every other LspServerError message stays Internal, since that variant legitimately carries genuine server faults too.
  • Consolidate the three bespoke JSON-RPC error codes (WORKSPACE_INDEXING_ERROR_CODE, SERVER_INITIALIZING_ERROR_CODE, STATELESS_SUBSCRIPTION_ERROR_CODE) into error.rs, so allocating the next code no longer requires checking two files.
  • Fix unsubscribe leaking a capped subscription slot when canonicalization fails (e.g. the file was deleted since subscribing): it previously fell back to the raw request URI as a lookup key, which almost never matches the canonical URI subscribe recorded it under. subscribe now also records a raw-to-canonical alias (bounded to one alias per canonical URI, pruned on either removal path), so a stale unsubscribe resolves to the right entry. A failed removal is now logged at debug level.

Test plan

  • cargo +nightly fmt --all -- --check
  • cargo clippy --all-targets --all-features --workspace -- -D warnings
  • cargo nextest run --workspace --all-features --lib --bins (1016 passed)
  • cargo test --doc --workspace --all-features
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • New regression tests for both error-classification sites and the unsubscribe alias-resolution path (including a bound/eviction test for the alias table)

Closes #496
Closes #499

…ectly, fix unsubscribe leak on deleted files

Route SubscriptionError::LimitReached through the mcp_error_kind
classifier instead of hand-mapping it to InvalidParams, matching
DocumentLimitExceeded's treatment (aggregate tracker state, not a
per-request bad parameter). Reclassify LspServerError as InvalidParams
only for the recognized position-out-of-range message shape that
sanitize_lsp_server_message already rewrites for display; every other
LspServerError message stays Internal. Consolidate the three bespoke
JSON-RPC error codes into error.rs.

unsubscribe previously fell back to the raw request URI whenever
canonicalization failed, which is exactly the case where a deleted
file's raw URI no longer matches the canonical key subscribe recorded
it under -- permanently leaking the subscription slot. subscribe now
records a raw-to-canonical alias (bounded to one alias per canonical,
pruned on either removal path) so a stale unsubscribe still resolves
to the right entry; a failed removal is now also logged at debug
level.

Closes #496
Closes #499
@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes mcpls-core mcpls-core crate changes labels Sep 21, 2026
@bug-ops
bug-ops enabled auto-merge (squash) September 21, 2026 13:48
@bug-ops
bug-ops merged commit 2179405 into main Sep 21, 2026
51 of 53 checks passed
@bug-ops
bug-ops deleted the fix/496-499-error-classification branch September 21, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation mcpls-core mcpls-core crate changes rust Rust code changes

Projects

None yet

1 participant