Skip to content

Surface JSON parse detail in streamable-HTTP 400 responses - #1844

Open
ump45nose wants to merge 1 commit into
modelcontextprotocol:mainfrom
ump45nose:contrib/d881e201499f
Open

Surface JSON parse detail in streamable-HTTP 400 responses#1844
ump45nose wants to merge 1 commit into
modelcontextprotocol:mainfrom
ump45nose:contrib/d881e201499f

Conversation

@ump45nose

Copy link
Copy Markdown

Summary

Surface JSON parse detail in streamable-HTTP 400 responses

Verification

dotnet test tests/ModelContextProtocol.AspNetCore.Tests -f net10.0 --filter 'FullyQualifiedName~StreamableHttpServerConformanceTests' (56 passed); new PostTruncatedJson theory + updated PostMalformedJson red-green verified (3 fail without the fix, 3 pass with it)

Related to #1842

AI assistance disclosure: AI was used to discover this opportunity and draft the change or text. The submission was checked against the prepared artifact and recorded verification evidence.

When the POST body cannot be parsed as a JSON-RPC message, the 400
InvalidRequest response was a fixed one-liner that discarded the
JsonException's reason and position. A body truncated by an intermediary
(proxy, gateway, or transport) is therefore indistinguishable from any
other malformed body without server-side logs (modelcontextprotocol#1842).

The catch now includes the parser message and line/byte position in the
error message, so the failure is diagnosable from the response alone.
The message prefix and the conformant id=null envelope are unchanged.
@ump45nose

Copy link
Copy Markdown
Author

Additional verification context: the change is limited to preserving the existing 400 InvalidRequest behavior while surfacing the caught JsonException message and its line/byte position. The focused net10.0 conformance run passed 56 tests, including the malformed-JSON case and the new truncated-JSON regression coverage tied to #1842.

GitHub currently shows no completed check jobs or reviews for this commit, so the evidence above refers to the recorded local verification only.

AI assistance disclosure: AI was used to discover this opportunity and draft the change or text. The submission was checked against the prepared artifact and recorded verification evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant