Repository navigation
Conversation
pskiran1
marked this pull request as ready for review
August 12, 2026 15:17
Contributor
Author
|
/ok to test 8b3dbaf |
Contributor
WalkthroughThe HTTP service now parses response request bodies explicitly, validates JSON-compatible content types, and uses tolerant JSON parsing. Unmatched routes return OpenAI-compatible JSON 404 responses. Integration tests cover request and routing errors. ChangesOpenAI-compatible HTTP error handling
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/llm/src/http/service/openai.rs`:
- Around line 2953-2956: Move the JSON Content-Type validation out of
handler_responses and into route middleware or a custom extractor that examines
request parts before Axum extracts body: Bytes. Ensure invalid media types
receive an immediate 415 response, while handler_responses continues to call
parse_json_request only after validation succeeds.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c950200f-5e3d-40f3-b90a-63087365bdda
📒 Files selected for processing (2)
lib/llm/src/http/service/openai.rslib/llm/src/http/service/service_v2.rs
This comment has been minimized.
This comment has been minimized.
pskiran1
marked this pull request as draft
August 12, 2026 16:00
pskiran1
marked this pull request as ready for review
August 12, 2026 16:49
Contributor
Author
|
/ok to test 8f65456 |
rmccorm4
reviewed
Aug 17, 2026
…setty/dis-2541-a4-malformed-non-json-http-response-body
Contributor
Author
|
/ok to test 8f65456 |
Signed-off-by: Sai Kiran Polisetty <spolisetty@nvidia.com>
rmccorm4
approved these changes
Aug 18, 2026
rmccorm4
enabled auto-merge (squash)
August 18, 2026 15:53
Contributor
Author
|
/ok to test 8f65456 |
nv-anants
approved these changes
Aug 18, 2026
rmccorm4
deleted the
spolisetty/dis-2541-a4-malformed-non-json-http-response-body
branch
August 18, 2026 16:58
ayaangazali
added a commit
to ayaangazali/dynamo
that referenced
this pull request
Aug 27, 2026
error envelope for a bad `Content-Type`, an oversized body and malformed JSON,
by reading the body through `read_json_request_body` and `parse_json_request`.
Eight handlers were left on the plain `Json<T>` extractor and still return
Axum's `text/plain` rejection, so the envelope depends on which endpoint the
client happened to call:
POST /v1/responses + Content-Type: text/plain
415 application/json {"message":"Expected request with Content-Type application/json",...}
POST /v1/embeddings + Content-Type: text/plain
415 text/plain Expected request with `Content-Type: application/json`
A client that parses the error body works against one endpoint and fails
against the other, for the same mistake and the same status code.
Route the remaining handlers through the same two helpers: embeddings,
classify, pooling, images, image edits, videos, video stream and audio speech.
They already took `HeaderMap` and already returned
`Result<Response, ErrorResponse>`, so each is a signature swap plus the two
lines ai-dynamo#13102 established.
`images_edits` validates `input_reference` and then delegates to `images`,
which now consumes a `Body` it has already read. The part of `images` after
parsing moves into `images_with_request`, called by both.
No change to any success path, and no change to the error text; only the
envelope and content type on the eight endpoints that were inconsistent.
Signed-off-by: ayaangazali <ayaangazali.work@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview:
This PR fixes non-JSON error responses on the OpenAI-compatible HTTP API. OpenAI clients expect error responses to use a JSON error envelope. Previously, some invalid requests returned plain-text or empty responses.
This PR returns the standard
{"message", "type", "code"}error envelope for:Content-Typeheaders onPOST /v1/responsesGET /v1/responses/{response_id}Details:
Responses request parsing
handler_responsespreviously used Axum'sJson<T>extractor. Because extractors run before the handler, invalid or missing JSON content types were rejected by Axum with a plain-text415 Unsupported Media Typeresponse. The handler now reads the request body directly and uses the existingensure_json_content_typeandparse_json_requesthelpers, consistent with the Chat Completions and Completions handlers.Unmatched routes
Added
unmatched_route_fallbackto return a JSON404response when no registered route matches the request path. The fallback is registered after routers are merged, since Axum permits only one custom fallback, and before service layers are applied so fallback responses include the same request-level behavior, such asx-request-id. Existing handler-level errors, such asModel not found, are unchanged.Validation
Added tests:
test_responses_non_json_content_type_returns_json_errortest_responses_malformed_json_returns_json_errortest_unknown_response_id_returns_json_404test_unknown_path_returns_json_404Manual verification against a frontend serving
Qwen/Qwen3.5-4B:POST /v1/responseswithContent-Type: text/plain415with plain-text body415with JSON error envelopePOST /v1/responseswithoutContent-Type415with plain-text body415with JSON error envelopePOST /v1/responseswith malformed JSON400with JSON error envelopeGET /v1/responses/resp_x404with empty body404with JSON error envelopeGET /v1/not_a_route404with empty body404with JSON error envelopeRegression checks:
POST /v1/responseswithapplication/json; charset=utf-8POST /v1/chat/completionswith an unknown modelModel not foundresponseGET /v1/modelsandGET /health200responses unchangedGET /metricsGET /v1/responses405response withAllow: POSTunchangedRelated Issues
🔗 This PR is linked to an issue:
🚫 This PR is NOT linked to an issue:
Summary by CodeRabbit