A request whose `id` is not an i64 or a string is parsed as a notification
维护者通常 3 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 62/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- rust
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Rust
- 星标
- 4k
- 派生
- 662
- 平均合并
- 3 天 10 小时
- 30 天内合并 PR
- 33
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/rust-sdk 的其他 Issue
-
Streamable HTTP client: a 401 or 403 with a JSON-RPC error body and no WWW-Authenticate loses its HTTP status可能已有人在做 @aton-of-data 于 2 天前认领。 未关闭bug P2 ready for work T-security T-transport
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/rust-sdk#1339 ·
维护者通常 3 天内回复
-
rmcp and rmcp-macros crates no longer include LICENSE (regression since 1.3.0)可能已有人在做 @Steeve-Crypto 于 2 天前认领。 未关闭bug P2 ready for work T-config
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/rust-sdk#1335 · 1 条评论 ·
维护者通常 3 天内回复
-
auth: refresh_token() requests offline_access that was never granted, so refreshes fail with invalid_scope可能已有人在做 @jstar0 于 5 天前认领。 未关闭bug P1 ready for work T-security T-transport
难度 2/5 1-3 小时 新手友好度 65/100
modelcontextprotocol/rust-sdk#1330 ·
维护者通常 3 天内回复
-
P3 question Stale T-documentation T-enhancement
难度 1/5 1 小时以内 新手友好度 86/100
modelcontextprotocol/rust-sdk#1155 · 1 条评论 ·
维护者通常 3 天内回复
-
bug P1 ready for work T-handler T-model
难度 4/5 3-5 天 新手友好度 35/100
modelcontextprotocol/rust-sdk#1347 ·
维护者通常 3 天内回复
查看 modelcontextprotocol/rust-sdk 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
-
state:triage-needed
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
scanaislop/aislop#482 ·
维护者通常 1 天内回复
-
docs(skills): issue-first should reference an existing Linear ticket instead of filing a duplicate未关闭documentation
难度 1/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复