Repository navigation
fix(proxy)!: return provider-matching 4xx for the LIT-8062 status code follow-ups - #45537
Conversation
… follow-ups - OCR multipart errors are 400 invalid_request_error on the file param - a missing model is a 400 on chat, responses and messages even with a wildcard deployment - responses max_output_tokens <= 0 reaches the provider instead of being raised to 16 - daily activity rejects end_date before start_date with a 400 - vector store file attributes are sent in full so the provider enforces its key limit - router-wide defaults no longer satisfy a param the Router takes positionally, or a model the router does not serve - a JSON null user_config is treated as absent
…lose router-default gaps - a missing model is rejected only when the wildcard would forward it into the target - moderation only counts router defaults for models get_model_list lists - user_config defaults and deployment params never satisfy a positionally bound param
… call on positional-param 400s
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
|
Merging this PR will not alter performance
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Drives every mode the fix branches on through a real proxy, Postgres, Redis and the scripted upstream: positional params against router, deployment and user_config defaults; moderation listed vs unlisted; unknown and a2a models; every user_config shape on chat, responses and messages, streaming and SDK clients; forwarding vs fixed-target wildcards for missing, null and empty models; Responses max_output_tokens edges; OCR parse errors; vector store file attributes; every daily activity route; and a provider outage mid burst plus a killed worker on a two-worker proxy. Product gaps found are skipped as BUG.
|
bugbot run |
|
bugbot run |
… a fallback chain serves
|
bugbot run |
|
bugbot run |
…e session Read the session's router binding, as the router does, instead of only checking that the request could resume one, so a subagent turn without a model on an unbound session is still rejected before a forwarding wildcard sends it upstream.
|
bugbot run |
- drop the wildcard missing-model gate: a model-less request behind a forwarding wildcard goes to the router and gets the provider's own status, as on main - drop the "model the router serves" check: router defaults count for any named model again, except moderation, where the Router merges them only for listed models - keep the positional-param, moderation and null user_config fixes
|
bugbot run |
|
/litereview code-review |
|
bugbot run |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4ec07c5. Configure here.
|
@litereview code-review |
|
| Request | Result |
|---|---|
| OCR with no file | 400, param: file |
| OCR with an empty file | 400, param: file |
| OCR with invalid JSON | 400 |
/v1/images/generations with no prompt |
400, param: prompt |
/v1/audio/speech with no input |
400, param: input |
/v1/completions with no prompt |
400, param: prompt |
/v1/moderations on an unlisted model with no input |
400, param: input |
user_config.default_litellm_params.prompt with no prompt |
400 |
user_config: null with client-side credentials allowed |
The request routed to real OpenAI and returned its 401 for a fake key, not a 400/500 |
What I accepted from the PR: live OpenAI transcripts on cb97794cb2 for max_output_tokens 0 and -1 and for 17 attributes, plus the reversed /team/daily/activity range. Through the GitHub API, I confirmed that responses/transformation.py, vector_store_files/transformation.py and common_daily_activity.py last changed in commit 68ef690755, before cb97794cb2. Their implementation matches head.
Still missing:
/usage/ai/chat: the PR claims the tool now returnsInvalid date range: <reason>.ai_usage_chat.pychanged inf894ecbe2a, after the live transcripts. The only evidence is a summary of integration cells that use a scripted model and scripted upstream, with no output attached.- What would satisfy it: a captured
/usage/ai/chatrun on head (or a commit with identical code) against a real model and DB. It should show the tool result for a reversed range and for a non-YYYY-MM-DD date, plus a valid-range control.
- What would satisfy it: a captured
- Audit-run artifacts: the "208 cells, 200 passed" claim has no CI artifacts or logs attached, so I could not inspect it.
Couldn’t complete
-
The required E2E gate is not fully met. The PR has no real, inspectable end-to-end run on current code for the
/usage/ai/chatinvalid-date tool message (ai_usage_chat.pychanged inf894ecbe2a, after the live transcripts). The integration audit claims (208 cells) have no attached artifacts. -
Mandatory E2E evidence gate: Verified:
-
I ran OCR, router-default/positional, moderation and
user_configcases on head against a real local proxy. -
The PR's live OpenAI transcripts cover Responses
max_output_tokens <= 0, 17 vector store attributes and the reversed daily-activity range. They were captured oncb97794cb2, and the implementation files are unchanged from there to head.
Unverified:
- The
/usage/ai/chatinvalid-date tool message.ai_usage_chat.pychanged after the live transcripts, and the only evidence is a summary of scripted-model integration cells with no attached output.
Checks and execution details
-
Not run · Mandatory E2E evidence gate (required): Verified:
-
I ran OCR, router-default/positional, moderation and
user_configcases on head against a real local proxy. -
The PR's live OpenAI transcripts cover Responses
max_output_tokens <= 0, 17 vector store attributes and the reversed daily-activity range. They were captured oncb97794cb2, and the implementation files are unchanged from there to head.
Unverified:
-
The
/usage/ai/chatinvalid-date tool message.ai_usage_chat.pychanged after the live transcripts, and the only evidence is a summary of scripted-model integration cells with no attached output. -
Passed · Targeted unit tests (optional):
uv run --frozen pytestontest_route_llm_request.py, OCRtest_endpoints.py,test_common_daily_activity.py, the vector store files and responses transformation tests, andtest_ai_usage_chat.py: 465 passed. -
Passed · Live proxy run on head (no provider needed) (optional): Ran
litellm --configwith routerdefault_litellm_paramsand sent curl requests: -
OCR with no file, empty file and bad JSON returned 400.
-
Image, speech, completions and unlisted-model moderation requests without the required param returned 400 naming the param.
-
A
user_configdefault prompt with no prompt returned 400. -
user_config: nullrouted through to OpenAI (401 for a fake key) instead of failing with 400/500. -
Passed · Commit provenance of PR evidence (optional): GitHub API:
-
cb97794cb2...f894ecbe2atouches onlyroute_llm_request.pyandai_usage_chat.pyunderlitellm/. -
f894ecbe2a...4ec07c5f34adds only the main merge and an OCR unit-test commit. -
The responses, vector store and daily-activity source files last changed in
68ef690755. -
Not run · Daily activity and real-provider cases rerun locally (optional): No Postgres or OpenAI credentials are available in this sandbox. I relied on the PR's live transcripts for files unchanged since they were captured.
View review · Reviewed 4ec07c5f3430
|
@litereview code-review |
✅ code-reviewScope: full · Full PR review. Completed · Some checks not run. Merge readiness: READYE2E evidence: VERIFIED. The PR includes before and after curl runs against a live proxy. The before runs use merge base Score: 4/5. I found no correctness defects. The score stays below 5 because a few failure branches have no live-run evidence. Those branches share code with the cases that were demonstrated. Correctness findingsNone. I traced each change from caller to observable result:
Breaking changeThe PR has three real contract changes: reversed daily-activity ranges, StandardsI checked the diff against
Judgement calls, not blockers:
SpecLIT-8062 isn't attached. I used the PR's own list of ticket cases as the requirements. The diff implements every claimed behavior change. The PR explicitly defers #21, #23 and #27 by product decision, and the description says why. I found no unrequested behavior beyond the documented Remaining verification gaps (optional)The PR doesn't show these OCR parse errors live: file over the size limit, invalid or empty JSON body, and Checks and execution details
I downloaded one linked Logs-page screenshot (
View review · Reviewed |
|
@litereview full |
✅ fullScope: full · Full PR review. Completed · Some checks not run. Verdict: no actionable defects foundI traced each changed item to its dependents and found no break that the PR doesn't already declare as intentional. The title carries the What I checked
Minor note, not a defect: the vector-store attribute filter still drops numeric and boolean values that OpenAI accepts. The old code did the same, so this is not a regression. Live proxy A/B: not run. I had no Postgres, real provider credentials, or proxy rig in this sandbox. Everything above comes from reading the code plus the unit tests below, not from observing a running proxy. Checks and execution details
View review · Reviewed |
TLDR
Problem this solves:
How it solves it:
invalid_request_errormax_output_tokens, date ranges and attributes reach the 400 pathIntentional product change: reversed daily-activity date ranges,
max_output_tokens <= 0on /v1/responses, and more than 16 vector store file attributes now return 400 where they used to return 200 with a silently changed requestUser Flow
Before: a developer who sends a bad request gets a 500 and assumes the gateway is down, or gets a 200 for a request the provider would reject
filepart, or with an empty fileinternal_server_errorand retryrouter_settings.default_litellm_params.promptset, POST /v1/images/generations with nopromptalso returns 500 (missing 1 required positional argument), and so do speech, text completions and moderationsmax_output_tokens: 0returns 200 because the gateway quietly raised it to 16, and GET /team/daily/activity with end_date before start_date returns an empty 200After: the same requests come back as client errors that say what to fix
filepart, or an empty fileinvalid_request_errorwithparam: "file"and the same messageMissing required parameternaming the paramExpected a value >= 16, but got 0), and the daily activity call returns 400end_date must be on or after start_dateLinear ticket
Resolves LIT-8062
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Real OpenAI and Anthropic calls, no mocks. Three proxy configs, all with
master_key: sk-lit8062:gpt-4o(openai/gpt-4o-mini),azure/doc-intel(an Azure Document Intelligence OCR deployment), plus a real OpenAI vector store and filegpt-image-1,gpt-4o-mini-tts,instruct(openai/gpt-3.5-turbo-instruct) andanthropic.claude-haiku-4-5, withrouter_settings.default_litellm_params: {prompt: "a red square", input: "router default input", max_tokens: 32}andallow_client_side_credentials: trueThe /usage/ai/chat cases run on the default config with
gpt-4oas the chat model and real spend rows in Postgres; the model is asked to quote the tool's result verbatim, and only the tool event and the model's answer are shown from the streamBodies are cut at about 230 characters where they run long
Before (9e2aae8, the merge base)
OCR multipart with no file
OCR multipart with an empty file
/v1/responses with max_output_tokens 0
/v1/responses with max_output_tokens -1
/team/daily/activity with end_date before start_date
Vector store file update with 17 attributes
/v1/images/generations with no prompt, router default prompt set
/v1/audio/speech with no input, router default input set
/v1/completions with no prompt, router default prompt set
/v1/moderations with no input on an unlisted model, router default input set
/v1/messages with
user_config: null/usage/ai/chat, team usage tool called with end_date before start_date
/usage/ai/chat, team usage tool called with a date that is not YYYY-MM-DD
/usage/ai/chat, team usage tool called with a valid range (control)
After (4ec07c5, the PR tip)
OCR multipart with no file
OCR multipart with an empty file
/v1/responses with max_output_tokens 0
/v1/responses with max_output_tokens -1
/team/daily/activity with end_date before start_date
Vector store file update with 17 attributes
/v1/images/generations with no prompt, router default prompt set
/v1/audio/speech with no input, router default input set
/v1/completions with no prompt, router default prompt set
/v1/moderations with no input on an unlisted model, router default input set
/v1/messages with
user_config: null/usage/ai/chat, team usage tool called with end_date before start_date
/usage/ai/chat, team usage tool called with a date that is not YYYY-MM-DD
/usage/ai/chat, team usage tool called with a valid range (control)
Dashboard (Logs page, head)
Each failed request below was found on the Logs page by its request id and its detail panel opened. OCR errors now write a failed-request row with the 400 instead of a 500
document.type: fileover JSONmax_output_tokens: 0, OpenAI's 400Walkthrough of the same flow:
Audit run (4ec07c5 vs the merge base 9e2aae8)
The 5
tests/integration/compatibility/test_status_code_followups*.pyfiles (208 cells) ran on a real proxy, Postgres, Redis and the scripted upstream:max_output_tokens0 and -1 and 17 vector store attributes give 200 on base and OpenAI's 400 on head; values 1 and 15, 16 attributes and model-less requests behind*->openai/*match base (OpenAI's own 400/404 forNone/Noneand"")Breaking change
Callers who relied on the gateway quietly fixing these requests now get a 400 and need to send valid values: daily-activity routes with end_date before start_date, /v1/responses with
max_output_tokensof 0 or less, and OpenAI vector store files with more than 16 attributes. Fix the request (swap the dates, sendmax_output_tokens>= 16, send at most 16 attributes); nothing else changes for requests that were already valid.Behavior changes
Removed / renamed
None
Intentional contract changes
/{user,team,tag,organization,customer,end_user,agent}/daily/activityand/user/daily/activity/aggregated) with end_date before start_date: 200 with empty results -> 400end_date must be on or after start_date. The date check runs before the permission check, as it already did for malformed dates, so a service-account key sending reversed dates to/user/daily/activity/aggregatednow gets this 400 instead of the 403max_output_tokensof 0 or less: the gateway used to raise it to 16 and return 200. It now sends the value as-is, so OpenAI returns its 400. This includes chat requests bridged to Responses withmax_tokens0 or -1, /v1/messages to an OpenAI model withmax_tokens: -1, andmax_output_tokens: false(sent as-is, so OpenAI rejects the boolean). Values 1 to 15 (andtrue) are still raised to 16type: file,reducto://ids): 500 -> 400invalid_request_error, withparam: "file"where it applies. These now also fire the failure callbacks and write a failed-request row to the Logs page, like other proxy-side 4xx errorsrouter_settings.default_litellm_params(anduser_configdefaults, and deployment-level params) no longer count as supplyingprompt/input/fileon image generation, speech, text completion and transcription, where the Router takes them positionally. Those requests used to 500 with a TypeError and now return 400get_model_listlists, matching where the Router merges them. Requests to an unlisted moderation model that used to 500 withKeyError: 'input'now return 400. Every other route counts router defaults for any named model, as on main. A moderation request withoutinputfor another team's internal model name was already a 400 and now saysMissing required parameter: 'input'instead ofThere are no healthy deployments for this modeluser_config: null(with client-side credentials allowed) is treated as absent instead of returning 400/500Invalid date range: <reason>instead of an empty dataset (reversed) orError fetching ... Please try again.(not YYYY-MM-DD). The global usage tool, whose query takes its dates without that check, answers exactly as on mainSilent regressions to watch
None. Earlier heads also added a proxy-side model check in front of
*->openai/*wildcards and a "does the router serve this model" check for router defaults. Each review round found requests that main served and those checks blocked (fallback chains, aliases, prompt managers, deployment hooks, Claude Code session routers), because the proxy was guessing what the router would do. f894ecb removes both checks, so those requests behave exactly as on main: a model-less request behind a forwarding wildcard reaches the provider and gets its own status (OpenAI's 404 forNone/None), and router defaults count for any named model except on moderationRegression tests
tests/integration/compatibility/test_status_code_followups.pyruns every case above against a real proxy and scripted upstream, and checks the outbound body or that no provider call was madetest_status_code_followups_usage_chat.pydrives /usage/ai/chat with a scripted model that picks reversed, invalid-month, slash-separated and valid datestests/integration/compatibility/test_status_code_followups_{defaults,requests,chaos}.pyare the audit matrix: every mode the fix branches on, through raw HTTP and the OpenAI and Anthropic SDKs, sync and async, plus the outage and killed-worker chaos cellstests/unit/proxy/test_route_llm_request.pypins the router-default check for each positional route,user_configand deployment-level params, unlisted moderation models, and a nulluser_configroute_llm_request.py, all killed by the unit file: ignore the positional set for deployment params, drop the positional set from the no-merge routes, drop the moderation listed-model check, keep a nulluser_configType
Bug Fix
Test
Caveats (if any)
Medium
temperature: nullon /v1/messages returns 200 (Anthropic returns 400). The gateway drops null params on purpose, so forwarding them would turn today's 200s into 400sallow_unmanaged_response_ids: trueturns it offfile/purposereturns FastAPI's 422 (OpenAI returns 400). Every FastAPI-validated form route answers 422 todaymax_tokens: 0on /v1/messages) and updating version #31 (empty vector store search query) are not gateway bugs: the providers themselves return 200Low
Missing required parameterinstead ofInvalid model name. Both are 400, and this matches main without a router default*->openai/*) still sendsNone/Noneto the provider and returns its status, and""is still forwarded as sent, both as on main. Not in the ticket's list of mismatchesBUGcells in the audit files: a router-wide defaultprompt/inputreplaces the caller's own value on image, text completion and speech; a JSON array body returns 500 on every route from the auth pre-checks;/gateway/daily/activitystill returns 200 for a reversed date rangemax_output_tokens <= 0as sent. Only the outbound request was checked for themFinal Attestation
ran /live-pr-risk and found no regressions/backward incompatible risks
REVIEWER MUST KNOW BEFORE APPROVING
max_output_tokens <= 0on Responses, including /v1/messages to an OpenAI model withmax_tokens: -1, and more than 16 vector store file attributes). In each case the gateway used to change the request silently instead of rejecting itroute_llm_request.pychanges in two places only: positionally bound params never count router,user_configor deployment defaults, and moderation only counts router defaults for listed models. A new Router method that takes a required param positionally has to be added to_ROUTE_TYPES_WITH_POSITIONAL_REQUIRED_PARAM