odysseus-dev/odysseus · error · HTTPException
Request parsing error: {e}
Error message
Request parsing error: {e} What it means
Catch-all for any non-JSONDecodeError exception while reading/parsing the streaming chat request (the outer try wraps the content-type check and body read). It converts unexpected transport-level failures into a 400 with the underlying exception text.
Source
Thrown at routes/chat_routes.py:880
"endpoint_label": actual_route.get("endpoint_label"),
}
# ------------------------------------------------------------------ #
# POST /api/chat_stream
# ------------------------------------------------------------------ #
@router.post("/api/chat_stream")
async def chat_stream(request: Request) -> StreamingResponse:
body = None
try:
if request.headers.get("content-type", "").startswith("application/json"):
try:
body = await request.json()
except json.JSONDecodeError as e:
raise HTTPException(400, f"Invalid JSON: {e}")
except HTTPException:
raise
except Exception as e:
raise HTTPException(400, f"Request parsing error: {e}")
_set_user_time_from_request(request)
form_data = await request.form()
message = form_data.get("message")
session = form_data.get("session")
attachments = form_data.get("attachments")
use_web = form_data.get("use_web")
use_research = form_data.get("use_research")
time_filter = form_data.get("time_filter")
preset_id = form_data.get("preset_id")
selected_endpoint_id = str(
form_data.get("selected_endpoint_id")
or (body or {}).get("selected_endpoint_id")
or ""
).strip()
# Issue #3229: API callers send JSON, not FormData. Read from the
# JSON body as fallback so callers who send {"allow_bash": true}View on GitHub (pinned to f9235ebbf1)
Solutions
- Read the exception text in the 400 response — it names the actual underlying failure
- Reproduce with a minimal curl request to rule out client/proxy mangling
- Ensure the client sends UTF-8 and does not abort before the body completes
Defensive patterns
Strategy: try-catch
Try / catch
try { await send(); } catch (e) {
if (e.status === 400 && /parsing error/i.test(e.message)) { logUnderlying(e.message); inspectProxyAndEncoding(); }
} Prevention
- Send UTF-8 bodies and complete requests (don't abort mid-upload)
- Bypass suspect proxies when diagnosing to isolate where the body gets corrupted
When it happens
Trigger: Body stream read errors (client disconnected mid-upload), unicode decode failures on non-UTF-8 bytes, malformed multipart framing when the endpoint falls through to request.form(), or starlette raising on malformed chunked encoding.
Common situations: Client aborted the upload; wrong charset declared; a debugging proxy re-encoding the request; framework-level incompatibilities after a Starlette/FastAPI upgrade changing body-reading semantics.
Related errors
- Invalid JSON: {e}
- text is required
- Invalid JSON
- session_id, original_text, and instruction are required
- HTTP ${res.status}
AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14).
Data as JSON: /api/errors/2b64a90edb5e7a66.
Report an issue: GitHub.