mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-30 01:08:33 +00:00
* fix(router): keep a caller's Anthropic key and forwarded headers off Bedrock fallbacks A router fallback from an Anthropic deployment onto bedrock or bedrock_mantle inherited the caller's api_key, so AWS received it as a bearer token instead of a SigV4 signature (#45309). The fallback hop now leaves that key behind and signs with the deployment's own credentials. The origin is the provider of the requested group's first attempt, or the group's sole provider when no attempt reached it. Same-provider fallbacks, Bedrock and Mantle bearer sharing, dict fallback targets that set api_key, and callers that send their own api_base keep today's behavior. The proxy now stamps the names of the client headers it forwards. On a fallback hop, the router re-checks model_group_settings.forward_client_headers_to_llm_api for the fallback group and drops only those stamped headers when the group is out of scope, plus the forwarded x-api-key copy when the key is left behind. * fix(router): keep blank keys, target base URLs and hook-set headers on Bedrock fallbacks Review follow-up for #45309. A blank caller api_key already turns off the env bearer and signs with SigV4, so it is no longer treated as a key to leave behind. A dict fallback target that sets api_base or base_url without its own api_key keeps the caller key, as a caller redirect does. The proxy now stamps a keyed digest of each forwarded header value instead of only its name, so a fallback removes a forwarded header only while it still holds that value. A pre-call hook that replaced it keeps its value, and the logged stamp reveals no header value. When every deployment of the requested group is Anthropic, that group decides the key owner on every attempt. A stream recovered in a new walk is built from the same request, so it cannot bring the caller key back onto Bedrock or Mantle. * fix(router): leave the caller key behind only on IAM-signed Bedrock fallbacks Narrows #45309 to its reported setup. A bedrock or bedrock_mantle fallback deployment that authenticates with a bearer of its own, its api_key or the provider's env bearer, still gets the caller's key as before, so shared gateways keep working. The key is dropped only when that provider's own bearer resolver (bedrock_bearer_token, resolve_mantle_bearer_token) finds no bearer, which keeps each provider's empty and missing api_key rules. * test(router): let the mid-stream continuation reach a prefill-capable Mantle deployment The continuation prefill check only routes a continuation to deployments that support assistant prefill, and the Mantle gpt-oss entry does not declare it, so the backup was filtered out. The backup now declares supports_assistant_prefill in model_info, and the test also asserts the second Mantle request carries the assistant prefill. * fix(router): keep the caller key on AWS fallbacks that set an explicit Authorization header On an AWS deployment the caller's api_key outranks an Authorization set in headers or extra_headers, because the bearer path writes its own Authorization. Dropping the key handed the call to that header instead, which changed an accepted precedence. The key is now kept whenever the request, the dict fallback target or the deployment sets an explicit Authorization header. The proxy-forwarded path never carries one, so the reported leak stays fixed. * fix(router): keep the caller key on AWS fallbacks behind a custom endpoint Scopes #45309 to the public AWS endpoint setup it reports. A bedrock or bedrock_mantle deployment that overrides its destination (api_base, base_url, aws_bedrock_runtime_endpoint, or the AWS_BEDROCK_RUNTIME_ENDPOINT / BEDROCK_MANTLE_API_BASE env vars) may be a gateway that takes the caller's bearer, and its auth intent cannot be inferred, so it keeps today's behavior. * fix(router): preserve request and fallback runtime endpoint credentials * fix(router): type the forwarded-header stamp and key mixed groups by membership The proxy reads the request through the existing typed request seam and builds the forwarded header stamp in a pure helper, so it adds no mutable parameter and no Unknown diagnostics, and writes it the same way caller_credential_fields is written. The not-a-dict branch is gone, since proxy_server_request is always the dict the proxy just built. In a requested group whose deployments mix providers, the caller key is kept on the group's own deployments (its order chain and retries) and left behind only on a deployment outside the group, whatever depth the walk reports. Tests cover the mixed group, a malformed SDK stamp, and a forwarding scope that is no longer configured. * fix(router): avoid exported stamp constants and cover unnamed default routes * test: remove unsupported unnamed caller-key route scenario * style: remove trailing blank line from fallback tests * fix(router): preserve fallback auth across defaults and stream recovery * test(router): preserve Claude Platform fallback authentication --------- Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| core | ||
| __init__.py | ||
| test_enforce_model_rate_limits.py | ||
| test_io_token_rate_limits.py | ||
| test_router.py | ||
| test_router_callback_hook_sequence.py | ||
| test_router_endpoints.py | ||
| test_router_entry_points.py | ||
| test_router_facade.py | ||
| test_router_fallbacks.py | ||
| test_router_fuzz_regressions_rust_only.py | ||
| test_router_get_deployments.py | ||
| test_router_helper_utils.py | ||
| test_router_host.py | ||
| test_router_max_parallel_requests.py | ||
| test_router_provider_endpoints.py | ||
| test_router_retries.py | ||
| test_router_surface_check.py | ||
| test_router_timeout.py | ||
| test_router_vector_store_endpoints.py | ||