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:
Mateo Wang 2026-08-19 10:43:27 -07:00 • committed by GitHub
commit 18d07e3a6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -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:

View file

@ -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: