mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(router): fail closed on missing named credentials
This commit is contained in:
parent
8c252d7b73
commit
413cb8076c
3 changed files with 41 additions and 0 deletions
|
|
@ -9635,6 +9635,7 @@ class Router:
|
|||
verbose_router_logger.warning(
|
||||
"Credential '%s' not found in credential_list", deployment.litellm_params.litellm_credential_name
|
||||
)
|
||||
return None
|
||||
credentials.update(credential_values)
|
||||
# Remove the credential name since we've resolved it
|
||||
credentials.pop("litellm_credential_name", None)
|
||||
|
|
|
|||
|
|
@ -241,6 +241,7 @@ class CredentialLiteLLMParams(BaseModel):
|
|||
api_key: str | None = None
|
||||
api_base: str | None = None
|
||||
api_version: str | None = None
|
||||
project_id: str | None = None
|
||||
## AZURE OAUTH ##
|
||||
# Without this field, ``get_deployment_credentials_with_provider``
|
||||
# round-trips ``litellm_params`` through a strict Pydantic dump and
|
||||
|
|
|
|||
|
|
@ -4539,6 +4539,45 @@ def test_get_deployment_credentials_with_provider_resolves_credential_name():
|
|||
litellm.credential_list = []
|
||||
|
||||
|
||||
def test_get_deployment_credentials_with_provider_fails_closed_for_missing_named_credential():
|
||||
router = litellm.Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "embedding-model",
|
||||
"litellm_params": {
|
||||
"model": "azure/text-embedding-3-small",
|
||||
"litellm_credential_name": "deleted-credential",
|
||||
},
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
with patch.object(litellm, "credential_list", []):
|
||||
credentials = router.get_deployment_credentials_with_provider(model_id="embedding-model")
|
||||
|
||||
assert credentials is None
|
||||
|
||||
|
||||
def test_get_deployment_credentials_with_provider_preserves_project_id():
|
||||
router = litellm.Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "embedding-model",
|
||||
"litellm_params": {
|
||||
"model": "watsonx/ibm/slate-125m-english-rtrvr",
|
||||
"api_key": "test-key",
|
||||
"project_id": "embedding-project",
|
||||
},
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
credentials = router.get_deployment_credentials_with_provider(model_id="embedding-model")
|
||||
|
||||
assert credentials is not None
|
||||
assert credentials["project_id"] == "embedding-project"
|
||||
|
||||
|
||||
def test_get_deployment_credentials_with_provider_bedrock_batch_fields():
|
||||
"""
|
||||
Test that get_deployment_credentials_with_provider returns the deployment's
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue