mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(mcp): make Unauthorized a frozen dataclass to keep the type budget flat
CredError's unauthorized payload was a pydantic BaseModel, whose base resolves as unknown in this repo's basedpyright (every model in the file trips reportUntypedBaseClass plus an unknown model_config), so the tagged-union case read as unknown and the public edge's challenge access added reportUnknownMemberType errors over the per-rule ceiling. A frozen dataclass is fully typed here, so error.unauthorized resolves directly with no cast or accessor and the per-rule basedpyright counts match base.
This commit is contained in:
parent
d8b3d6d345
commit
a42fb2fd11
1 changed files with 3 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ union (see `result.py`), not `expression.Result`.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import Annotated, Literal, Mapping, Optional
|
||||
|
||||
|
|
@ -59,14 +60,14 @@ class AuthSpecKind(str, Enum):
|
|||
aws_sigv4 = "aws_sigv4" # AWS SigV4 per-request signing (e.g. Bedrock AgentCore)
|
||||
|
||||
|
||||
class Unauthorized(BaseModel):
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class Unauthorized:
|
||||
"""A 401 plus the optional challenge a client needs to recover.
|
||||
|
||||
``detail`` is the human message; ``www_authenticate`` and ``body`` carry a scheme-specific
|
||||
challenge (e.g. BYOK's provisioning prompt) so the edge can reproduce it verbatim.
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(frozen=True)
|
||||
detail: str
|
||||
www_authenticate: Optional[str] = None
|
||||
body: Optional[Mapping[str, str]] = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue