You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deeply-nested-body test fails on macOS: rejected as INVALID_REQUEST (-32600) instead of PARSE_ERROR (-32700) #3146
The response status is 400 in both cases; only the JSON-RPC error code differs. The test expects the RecursionError raised while parsing the deeply nested body to classify as a parse error, but on Darwin it surfaces as INVALID_REQUEST, so the recursion limit is evidently being hit in a different layer there (macOS threads run with a smaller default stack, which moves where the recursion guard strikes).
This is unrelated to any open PR: it fails identically on current main (3a6f299) and on feature branches, reproduced across repeated runs on macos-latest. Repro:
uv sync --frozen
uv run --frozen pytest tests/server/test_streamable_http_modern.py::test_modern_post_with_deeply_nested_body_is_parse_error_not_a_crash
CI currently runs Ubuntu and Windows only, which is why this has gone unnoticed; worth deciding separately whether macos-latest should join the matrix.
Reproduced on a real Mac, but the OS is a red herring — this is a CPython version boundary, and the server behavior on 3.14 is arguably the correct one.
Machine data — macOS 26.5.1 arm64 (M-series), same commit (6affe5c):
Python 3.12.13: test PASSES
Python 3.14.6: test FAILS with -32600 (as reported)
Actual divergence — the recursion guard never fires on 3.14; parsing succeeds:
Verified the two pieces in isolation: pydantic_core.from_json behaves identically on both (2.41.5, same ValueError), but stdlib json.loads diverges — on 3.14 it parses this depth without raising. So the body is valid JSON that just isn't a valid JSON-RPC request, and INVALID_REQUEST is the spec-correct answer for that. The failure path never touches the PARSE_ERROR branch.
Two consequences:
Since the divergence is in stdlib json, not the OS, this should reproduce on Linux + 3.14 as well (I only verified the stdlib divergence locally, not the full server test on Linux). Which means "add macos-latest to the matrix" is pointing at the wrong axis — adding 3.14 to the existing Linux matrix would catch this regardless of OS.
The server looks fine on 3.14: structured 400, no crash. What needs maintenance is the test's premise ("deep nesting makes json.loads raise RecursionError"), which stopped being true in 3.14.
Fix directions for the test:
Make it version-aware (≤3.13: PARSE_ERROR; 3.14+: INVALID_REQUEST), or
Keep the crash-guard intent with input that is unparseable on all versions (e.g., 100k nesting with a truncated tail — never valid JSON anywhere), and assert the parsed-but-wrong-shape case separately as INVALID_REQUEST.
Happy to send a PR for option 2 — it keeps the crash-guard assertion deterministic across interpreters.
Fixed in #3610. Thanks for the analysis and the PR offer above: the fix follows your second option, so the test body is now left unterminated and can't parse on any interpreter. The server code is untouched.
I reproduced the failure on Linux by raising the stack limit, but haven't run the fix on a Mac. If it still fails there, please open a new issue.
Adding macos-latest to CI has its own issue now, #3597.
Activity
JingHao-Leon commentedon Sep 22, 2026
Reproduced on a real Mac, but the OS is a red herring — this is a CPython version boundary, and the server behavior on 3.14 is arguably the correct one.
Machine data — macOS 26.5.1 arm64 (M-series), same commit (6affe5c):
Actual divergence — the recursion guard never fires on 3.14; parsing succeeds:
Verified the two pieces in isolation:
pydantic_core.from_jsonbehaves identically on both (2.41.5, same ValueError), but stdlibjson.loadsdiverges — on 3.14 it parses this depth without raising. So the body is valid JSON that just isn't a valid JSON-RPC request, and INVALID_REQUEST is the spec-correct answer for that. The failure path never touches the PARSE_ERROR branch.Two consequences:
Fix directions for the test:
Happy to send a PR for option 2 — it keeps the crash-guard assertion deterministic across interpreters.
maxisbey commentedon Oct 2, 2026
Fixed in #3610. Thanks for the analysis and the PR offer above: the fix follows your second option, so the test body is now left unterminated and can't parse on any interpreter. The server code is untouched.
I reproduced the failure on Linux by raising the stack limit, but haven't run the fix on a Mac. If it still fails there, please open a new issue.
Adding
macos-latestto CI has its own issue now, #3597.AI Disclaimer