Repository navigation
fix(frontend): treat an absent Content-Type as JSON #13268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vLLM does not explicitly set this strictness check to True, but in recent versions of vLLM 0.26.0+ -- It uses a newer FastAPI version and inherits FastAPI’s default which is newly strict by default :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chanh just want to double check if we really want to allow empty content-type, rather than continue to reject it. It seems like latest
vllm serveversions also reject it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, and the PR's premise is wrong. I checked the FastAPI source rather than argue from memory, and it does not say what my description claims.
strict_content_typelanded in FastAPI 0.132.0 and defaults toDefault(True):vLLM 0.26.0 builds
FastAPI(lifespan=lifespan)with no override, so it inherits the strict default, exactly as you said. My PR description asserts "the strict variant is opt-in and defaults off" — that was true before 0.132.0 and is false for every FastAPI version vLLM 0.26.0 accepts. The production behaviour I measured was against an older vLLM, and I generalised from it without checking the current default. My mistake.One correction to both of us, though: under strict, FastAPI does not return 415. The enforcement is a fallthrough, not a rejection (
routing.py0.136.1, L409-426):With strict on and no
Content-Type,json_bodystaysUndefined, the body is handed to the model as raw bytes, and Pydantic validation fails — sovllm serveanswers 422, not 415. Two further details that matter here:if not content_type_valueis falsy for the empty string as well, so FastAPI groups absent and empty identically. My PR added a separate "empty → accept" branch; the grouping is right, the outcome is not.Content-Typenever reaches it.So the honest picture is that neither current Dynamo nor this PR matches vLLM: Dynamo returns 415, vLLM returns 422, and this PR returns 200.
Given that, plus the CSRF rationale FastAPI documents for the default — a browser can send a no-
Content-Typecross-origin POST with no CORS preflight — I don't think "accept it" is defensible. I'd rather not ship it.Two options, and I'll take your call:
vllm servesees the same status. No change in what is accepted, only in how the rejection is reported.I lean toward (1) — the divergence is cosmetic, and 415 is arguably the more correct status for this condition regardless of what FastAPI happens to do. Say the word and I'll close it, or push (2).
Either way I'll drop the "FastAPI treats an absent Content-Type as JSON" claim from the description so it doesn't mislead anyone reading the history.