Repository navigation
Conversation
Recover the Serde error and field path for standard list and startup results that fall through to CustomResult. Preserve existing result classification, success handling, and custom request behavior.
Contributor
|
@michaelneale is on triage rotation this week and is the reviewer for this one. Labels come from the PR labeler. Please review the change. Automated triage. Labels are a first pass and the assigned maintainer has the final say. |
This branch has not been deployed
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.
Typed client calls now report the field path and underlying Serde error when an invalid standard list or startup result falls through to
CustomResult. Refs #1415.Motivation and Context
A
tools/listreply with a missinginputSchemaon its second tool used to produceUnexpectedResponse. The untaggedServerResultenum discarded the failed typed decode and retained the JSON asCustomResult. The client knew which method it had called, but discarded that context at the mismatch. Startup similarly returnedExpectedInitResultwith a debug rendering of the response.After the change, the same tool reply reports
invalid tools/list result at tools[1]: missing field `inputSchema`and exposes aserde_json::ErrorviaError::source(). The typed error path deserializes the retained JSON by reference. It runs for the four standard list methods, legacyinitialize, andserver/discover. Auto mode uses the same startup paths, including the legacy error stored inLegacyFallbackFailed.How Has This Been Tested?
The nine wire-level tests exercise a Tokio duplex peer. On upstream
165f8fd, all eight diagnostics cases failed at the missing-source assertion and the compatibility case passed. All nine pass with the patch under all features, the non-localfeature set, and the minimalclient,transport-async-rwset. The tests cover a valid reply after a malformed list, the four list result types, legacy initialization, Discover, Auto, legacy fallback, a recognized wrong result, and a raw custom result.Windows x86-64, Rust 1.96.1:
cargo test --offline --all-featureswith the Windows baseline filters: 1,214 passed, 32 ignored, 3 filtered.cargo test --offline -p rmcp --features "$FEATURES"with the CI's 29 non-localfeatures: 1,819 passed, 18 ignored, 8 filtered. The additional five filters cover the JS/Python harnesses requiringnpmoruv.cargo test --offline -p rmcp --lib --no-default-features: 206 passed.cargo +nightly fmt --all -- --check, strict all-targets Clippy with all features and the 29 non-localfeatures, andcargo check --offline --workspace --all-targets: passed.cargo +1.88.0 check --offline --all-targets --all-featuresandcargo build --offline -p rmcp --no-default-features --features client: passed.The three baseline filters were
default_http_client_preserves_connection_failure_cause(#1364) andrmcp_crate_ships_license/rmcp_macros_crate_ships_license(symlink placeholders in this Windows checkout). The results above are local Windows results.Breaking Changes
The two public error enums are already non-exhaustive. These cases now return
ResponseDecode; consumers can inspect the method, path, and source. Valid results and custom requests keep the existing wire classification. A reply classified as a different known result still follows the existing unexpected-result handling.Types of changes
Checklist
Additional context
serde_path_to_erroris optional underclientand is already used transitively in the workspace. The error API exposesserde_json::Erroras the source. Scope discussionOpenAI Codex investigated the issue, implemented the fix and tests, ran local validation, and drafted this PR.