A request whose `id` is not an i64 or a string is parsed as a notification
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 62/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- backend-api-design
Direzione di ricerca
Start with the JsonRpcMessage untagged enum and NumberOrString parsing in the message model; the issue provides a reproducer using ClientJsonRpcMessage and serde_json::from_str. Check how parsing distinguishes requests from notifications and how invalid ids can be reported as -32600 Invalid Request. Done means the listed id cases no longer silently parse as notifications.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
JsonRpcMessage is #[serde(untagged)]. When id is present but does not deserialize as NumberOrString (i64 or string), the Request variant fails and the message falls through to Notification, which ignores the extra id field. The server then never answers, so the client waits until its own timeout instead of getting -32600 Invalid Request.
To Reproduce (main at 808124b)
let raw = r#"{"jsonrpc":"2.0","id":1.0,"method":"tools/list"}"#;
let msg: rmcp::model::ClientJsonRpcMessage = serde_json::from_str(raw).unwrap();
assert!(matches!(msg, rmcp::model::ClientJsonRpcMessage::Request(_))); // fails: Notification
Same result for 9223372036854775808 (i64::MAX + 1), 1e2, 1.5, true and null. 9223372036854775807 parses as a request.
Expected behavior
A message that carries id and method is a request. If the id is not one the SDK supports, reject it with -32600 rather than treating it as a notification. 1.0 and 1e2 are integral JSON numbers and could reasonably be accepted as 1 and 100.
Additional context
Found by running the same request ids through several SDKs. The Go SDK has a related report in modelcontextprotocol/go-sdk#1376. I checked message parsing only, not a live server.
I'd like to send a fix: decide request vs notification by the presence of id, and report an invalid id as an error.
AI disclosure: found and drafted with Claude Code; I reviewed it and ran the cases above.
- Lingua principale
- Rust
- Stelle
- 4k
- Fork
- 662
- Merge medio
- 3g 20h
- PR unite (30g)
- 30
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/rust-sdk
-
Streamable HTTP client: a 401 or 403 with a JSON-RPC error body and no WWW-Authenticate loses its HTTP statusForse già presa @aton-of-data l’ha presa 5 giorni fa. Apertabug P2 ready for work T-security T-transport
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/rust-sdk#1339 ·
I maintainer di solito rispondono entro 2 giorni
-
auth: refresh_token() requests offline_access that was never granted, so refreshes fail with invalid_scopeForse già presa @jstar0 l’ha presa 7 giorni fa. Apertabug P1 ready for work T-security T-transport
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
modelcontextprotocol/rust-sdk#1330 ·
I maintainer di solito rispondono entro 2 giorni
-
P3 question Stale T-documentation T-enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
modelcontextprotocol/rust-sdk#1155 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Expose OAuth discovery and registration results for application-owned flowsForse già presa @connor4312 l’ha presa oggi. Apertaenhancement P2 ready for work T-security
modelcontextprotocol/rust-sdk#1371 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Two rmcp tests fail on Windows: connection-refused text check and `npm` spawn in test_with_jsForse già presa @bolinfest l’ha presa 1 giorno fa. Apertabug P2 ready for work T-test
modelcontextprotocol/rust-sdk#1364 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di modelcontextprotocol/rust-sdk
Issue simili
-
area: compat area: parsing bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
reubeno/brush#1526 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
OFN writer emits `DocIRI` as a bare IRI, which becomes a version IRI or a parse error on re-readAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
phillord/horned-owl#338 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
stackabletech/operator-rs#1301 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
jmcnamara/rust_xlsxwriter#205 · 4 commenti ·