fix(json-rpc): use -32600 for valid-JSON non-object bodies#1483
Conversation
Per JSON-RPC 2.0 §5.1, `-32700 Parse error` is reserved for "Invalid JSON was received by the server". A body of `123`, `"str"`, `true` or `null` is well-formed JSON — parsing succeeded — but is not a valid Request object, so it must be `-32600 Invalid Request`. Closes #1480 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughValid JSON primitive bodies are now classified as JSON-RPC Invalid Request errors, with parameterized HTTP and WebSocket tests covering strings, numbers, booleans, and null. ChangesJSON-RPC validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #1480
processJsonRpcBody()returned-32700 Parse errorfor any body that was not an object, but by that pointJSON.parsehad already succeeded. Per JSON-RPC 2.0 §5.1,-32700is reserved for "Invalid JSON was received by the server"; a body of123,"str",trueornullis well-formed JSON that simply is not a valid Request object, which is-32600 Invalid Request.Truly malformed JSON still returns
-32700— that path is thecatcharoundreq.json()/message.json()and is untouched.Regression tests added on both the HTTP and WebSocket handlers; both fail before the change (6 failures) and pass after.
🤖 Generated with Claude Code
Summary by CodeRabbit
null.