fix(routes): answer non-message POST /mcp bodies with 400 Invalid Request #286
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 204 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.318
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #286"
general
weight: 0.35
rozzilla
Summary
POST /mcppassed every parsed body toprocessMessage, which assumes an object.null, numbers, strings andtext/plainbodies made itsinchecks throw, and an object with none ofmethod/result/errorthrewInvalid JSON-RPC message. Both came back as HTTP 500 with-32603.The route now checks the body first. Anything that is not a JSON-RPC message gets HTTP 400 with a
-32600Invalid Request error andid: null, and no SSE session is created for it. Batches still go toprocessMessage, which already refuses them.Client-posted JSON-RPC responses (
{jsonrpc, id, result}/{jsonrpc, id, error}) already returned 202 on main after #241, which routes them toonClientResponse. This PR adds regression tests for that path: both shapes, with and without SSE, plus a legacy (2025-03-26, noMCP-Protocol-Versionheader) client answeringmcpElicitand resolving a waiter keyed by id.| Body | Before | After |
|---|---|---|
|
null,42,"x",true| 500 / -32603 | 400 / -32600 ||
text/plainbody | 500 / -32603 | 400 / -32600 || object with no
method/result/error| 500 / -32603 | 400 / -32600 || client
result/errorresponse | 202 (since #241) | 202, covered by tests |Malformed JSON and other body-parser errors are left to #230.
Breaking change
An object with none of
method,resultorerrornow gets 400 /-32600instead of 500 /-32603. The test intest/index.test.tsthat asserted the old 500 has been updated.Fixes #251
🤖 Generated with Claude Code
https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM