Repository navigation
Classify malformed-multimodal rejects as invalid_request - #27451
Conversation
When a multimodal request fails validation (e.g. bad base64 input), return a structured error with type=invalid_request_error and code=400 instead of a bare error message. Also detect client disconnects in the streaming path and exit cleanly instead of emitting a 400. In the multimodal processor, re-raise ValueError separately from RuntimeError so callers can distinguish bad input (4xx) from internal failures (5xx), and chain the original exception for better traceability. Co-authored-by: cctry <cctry@meta.com> Co-authored-by: cctry <cctry@fb.com>
|
/tag-and-rerun-ci |
There was a problem hiding this comment.
Code Review
This pull request improves error handling in the HTTP server and multimodal processors. Specifically, it handles client disconnects gracefully during streaming, structures streaming ValueError responses as 400 errors, and propagates ValueErrors during multimodal data loading to avoid 500 server errors. Feedback highlights two main areas for improvement: first, truncating the raw data string in base_processor.py exception messages to prevent log bloat and memory overhead from large base64 payloads; second, unifying the error response format between the streaming and non-streaming paths in http_server.py to ensure API consistency.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Large base64-encoded inputs (e.g. high-res images) can produce massive error messages. Truncate the data representation to 100 characters in both ValueError and RuntimeError paths.
…#27451) Co-authored-by: cctry <cctry@meta.com> Co-authored-by: cctry <cctry@fb.com>
Summary
type=invalid_request_errorandcode=400instead of a bare error message.ValueErrorseparately fromRuntimeErrorso callers can distinguish bad input (4xx) from internal failures (5xx), and chain the original exception viafrom e.Original commits
1bce350b1Test plan
"type": "invalid_request_error"and"code": 400.CI States
Latest PR Test (Base): 🚫 Run #27066493925
Latest PR Test (Extra): ❌ Run #27066493871