mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
Merge pull request #37432 from BerriAI/litellm_e2e_tag_denial_reason
test(e2e): pin the tag-routing denial to its actual cause
This commit is contained in:
commit
18d07e3a6b
2 changed files with 7 additions and 1 deletions
|
|
@ -75,6 +75,8 @@ class NetworkError(BaseModel):
|
|||
|
||||
class UnauthorizedError(BaseModel):
|
||||
kind: Literal["unauthorized"] = "unauthorized"
|
||||
# litellm 401s for key auth, model access, and tag routing alike, so keep the body to tell them apart.
|
||||
body: str = ""
|
||||
|
||||
|
||||
class RateLimitedError(BaseModel):
|
||||
|
|
@ -289,7 +291,7 @@ def _classify[R: BaseModel](
|
|||
resp: requests.Response, response_type: type[R]
|
||||
) -> Result[R]:
|
||||
if resp.status_code == 401:
|
||||
return UnauthorizedError()
|
||||
return UnauthorizedError(body=resp.text)
|
||||
if resp.status_code == 429:
|
||||
return RateLimitedError(body=resp.text)
|
||||
if not resp.ok:
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ PLAIN_MODEL = "anthropic/claude-sonnet-5"
|
|||
CHEAP_MODEL = "anthropic/claude-haiku-4-5"
|
||||
STRONG_MODEL = "openai/gpt-5.6"
|
||||
MAX_TOKENS = 16
|
||||
TAG_DENIAL_MESSAGE = "Not allowed to access model due to tags configuration"
|
||||
PLAIN_SERVED = frozenset({PLAIN_MODEL, "claude-sonnet-5"})
|
||||
CHEAP_SERVED = frozenset({CHEAP_MODEL, "claude-haiku-4-5"})
|
||||
EMBEDDING_MODEL = "openai/text-embedding-3-small"
|
||||
|
|
@ -442,6 +443,9 @@ class TestUntaggedTierDeployments:
|
|||
assert isinstance(result, UnauthorizedError), (
|
||||
f"expected the tagged direct call to an untagged deployment to be denied with 401, got {result}"
|
||||
)
|
||||
assert TAG_DENIAL_MESSAGE in result.body, (
|
||||
f"expected the denial to come from tag routing, got a 401 reading {result.body[:300]}"
|
||||
)
|
||||
|
||||
|
||||
class TestResponsesApiTagRouting:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue