A request whose `id` is not an i64 or a string is parsed as a notification
Mantenedores costumam responder em até 3 dias
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 62/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- rust
- Domínio
- backend-api-design
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Rust
- Estrelas
- 4k
- Forks
- 662
- Merge médio
- 3d 19h
- PRs com merge (30d)
- 35
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de modelcontextprotocol/rust-sdk
-
Streamable HTTP client: a 401 or 403 with a JSON-RPC error body and no WWW-Authenticate loses its HTTP statusTalvez já em andamento @aton-of-data assumiu há 3 dias. Abertabug P2 ready for work T-security T-transport
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
modelcontextprotocol/rust-sdk#1339 ·
Mantenedores costumam responder em até 3 dias
-
auth: refresh_token() requests offline_access that was never granted, so refreshes fail with invalid_scopeTalvez já em andamento @jstar0 assumiu há 6 dias. Abertabug P1 ready for work T-security T-transport
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
modelcontextprotocol/rust-sdk#1330 ·
Mantenedores costumam responder em até 3 dias
-
P3 question Stale T-documentation T-enhancement
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
modelcontextprotocol/rust-sdk#1155 · 1 comentário ·
Mantenedores costumam responder em até 3 dias
-
Clean up sessions after legacy initialize parsing failsTalvez já em andamento @bolinfest assumiu há 1 dia. Abertabug P2 ready for work T-transport
modelcontextprotocol/rust-sdk#1357 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 3 dias
-
Expose body-free HTTP status and Retry-After metadataTalvez já em andamento @bolinfest assumiu há 1 dia. Aberta
modelcontextprotocol/rust-sdk#1356 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 3 dias
Todas as issues de modelcontextprotocol/rust-sdk
Issues semelhantes
-
rustix::termios::Termios::OutputModes does not expost some const e.g. OLCUC for musl and macOSAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
bytecodealliance/rustix#1706 · 1 comentário ·
Mantenedores costumam responder em até 11 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
wormhole-foundation/wormhole#5062 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
RUSTSEC-2026-0348: Brotli certificate decompression can allocate up to 1 GiB before authenticationAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 60/100