Repository navigation
fix(router): keep one caller's own bad credential from cooling down a shared deployment - #53431
Conversation
…ed deployment cooldown
…ployment A call that ran with a provider credential or target the caller sent (an AWS key or profile, Vertex credentials or project, an Azure AD token or api_version, an OpenAI organization) and that differs from the deployment's configured value no longer cools down the shared deployment, so one caller's bad value cannot lock every other caller out of the model group.
…on every failure path A caller credential (AWS keys and profile, Vertex credentials, an Azure AD token) is blamed for any failure, a target (Azure api_version, AWS region, Vertex project and location) only for a 404, and an OpenAI organization only for a 401 or 403. A value that matches the environment default litellm reads counts as the deployment's own. Both caller rules now run inside the shared failure exits, so the walk, a stream that fails before its first chunk and a failed fallback hop all spare the shared deployment the same way.
[Medium impact] The PR appears safe to merge with the previous test timing issue fixed.
|
…azure_ai ignores next to an api key
…, drop env and provider-precedence rules
|
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 d40072b. Configure here.
| _CallerField("vertex_location", _NOT_FOUND, ("vertex_ai_location",)), | ||
| _CallerField("vertex_ai_location", _NOT_FOUND, ("vertex_location",)), | ||
| ) | ||
| _AZURE_FIELDS: Final = (_CallerField("azure_ad_token", _ANY_FAILURE), _CallerField("api_version", _NOT_FOUND)) |
There was a problem hiding this comment.
Nit, non-blocking. With a caller azure_ad_token we skip the cooldown on any failure, so a 429 or 500 from Azure on that request also doesn't count against the deployment. I checked is_caller_credential_failure at this commit and it returns True for 401, 429 and 500 alike. Probably fine since other callers' failures still count, but maybe worth limiting the token to 401/403 like organization? In this PR or a follow-up at some point
There was a problem hiding this comment.
Good catch, done in 05b6c87. A caller Azure token or Vertex credentials now only spare the deployment on a 401 or 403.
…for an auth rejection
…ey pick can cause
…ex stream cooldown test
| _CallerField("aws_region_name", _NOT_FOUND), | ||
| ) | ||
| _VERTEX_FIELDS: Final = ( | ||
| _CallerField("vertex_credentials", _AUTH_REJECTED_OR_NOT_FOUND, ("vertex_ai_credentials",)), |
There was a problem hiding this comment.
Nit, non-blocking. Caller vertex_credentials now skip the cooldown on any 404, even when the deployment sets its own project. I ran it on the integration rig with a deployment that has vertex_project set and a model the provider answers 404 for everyone. Before this PR the next caller got the cooled down group. Now, if the failing caller sent their own valid credentials, the deployment is never cooled down, and the request still went to the deployment's project, so the caller's credentials could not have caused the 404. Maybe only count the 404 against the caller when the deployment has no project set? In this PR or a follow-up at some point
Also reran the Azure token case on the rig after your fix, 429 and 500 cool the group down again, and the 36 integration tests pass
Main's BerriAI#53431 added a provider-field is_caller_credential_failure next to the Entra check. The PR's Entra or Databricks OAuth check is now is_caller_oauth_credential_failure, and the Rust router's health callbacks call it in place of the old Entra name, so the alias goes away. The shared helper reuses main's _call_credential_values and _configured_by_precedence _RejectionT drops its Final, since main's LIT010 now flags a Final type variable
Handwritten 1-3 sentence description
[insert handwritten description here]
Details
TLDR
Problem this solves:
How it solves it:
User Flow
Before: one app sends a bad credential of its own, and every other app on the same model is locked out for 60 seconds
shared-azureand allows callers to send their own credentials (allow_client_side_credentials: true)"azure_ad_token": "not-a-real-token"and gets 401shared-azureand gets 429 "No deployments available ... All deployments for selected model are in cooldown""organization": "org-bogus"to an OpenAI model or"api_version": "1999-01-01"to AzureAfter: App A still gets its own error, and App B keeps getting answers
api_version)shared-azureand gets 200?api-version=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 moreDelays 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
Before runs at the merge base
edf8d5c57ea. After runs at05b6c8756bd. The tipaf425b4d98aonly adds a 404 to the statuses caller Vertex credentials can be blamed for, which no live scenario below sends, and its unit case fails without it and passes with it. Real Azure OpenAI, OpenAI, Vertex AI and Bedrock calls through a live proxy with two workers and one dedicated Redis.Each scenario gets its own model group so cooldowns never leak between scenarios. For each one, a plain caller calls first, then the caller with their own field, then two more plain callers (and two plain callers on the fallback target where there is one). "Guard" scenarios use a deployment whose own key is revoked, and must cool down the same way before and after.
The Bedrock legs run with PR #53362 applied on top of both commits, since that PR is what turns a caller's missing AWS profile into a 401 (on main it is a 500 that never cools down, and a bad caller AWS key answers 403, which never cools down either).
Shared setup: Redis, proxy command, env var names
--reloadis dropped because each leg runs from a cleangit archiveof its commit, and with--reloaduvicorn serves one worker. BothStarted server processlines appear in every leg's log.scenarios.py (scenario list, shared by config and client)
gen_config.py (writes config.yaml from the scenarios)
Generated config.yaml
run_proof.py (the client, exactly as run)
Run with
python run_proof.py <port>for the main set, andSCENARIO_SET=bedrock python run_proof.py <port>for the Bedrock set.Before (edf8d5c)
Every regression scenario locks every other caller out with 429 cooldown, fallback targets included. On
/v1/responsesfor Azure, and on/v1/messagesand/v1/responsesfor OpenAI, the caller's field never reaches the provider, so those routes were never affected. Two Azure calls in this leg hit Azure's own throttling (429 RateLimitError from Azure, not a cooldown).Main set, edf8d5c
Bedrock set with #53362 applied, edf8d5c
After (05b6c87)
Every regression scenario keeps serving other callers, fallback targets included. Every guard still cools down exactly as before, including a revoked admin key hit by an Azure SDK style
?api-version=query param or a different bodyapi_version.Main set, 05b6c87
Bedrock set with #53362 applied, 05b6c87
Recordings
Devin session b31894f9, real Azure, shared deployment, one caller sends its own bad
azure_ad_token(recorded at1acc795acb1, before the rule was simplified, same outcome for this case):edf8d5c57ea: video, screenshot. App B gets 429all_deployments_in_cooldownwith no call to Azure1acc795acb1: video, screenshot. App B gets 200 from AzureBlack-box tests
tests/integration/routing/test_caller_credential_failure_cooldown.pyruns a real proxy against a scripted upstream. Red at the tests-only commit, green three fresh runs in a row at the fix.?api-version=) with the deployment's key rejectedDevin run 75dde093 at tests commit
fa855c7f4cfand tip042389e88d9. Its one broken case (/v1/messagesstream with an OpenAI org, which the scripted upstream could not answer, so it 501'd at both commits) was dropped. Confirming runs on8d803f1417fas the tests commit: b900053e at1acc795acb1(21 red, 15 green, then 36/36 three times), and 7d0022b7 at the tipd40072bcb03.Type
🐛 Bug Fix
✅ Test
Caveats (if any)
Medium
organizationand revoked admin key both answer 401api_versionand wrong admin deployment name both answer 404Low
Final Attestation