fix(typing): preserve runtime row shapes at jwt mapping and team fetch seams

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Devin AI 2026-08-10 14:04:56 +00:00
parent cb2b282d47
commit ce13ffa469
6 changed files with 33 additions and 22 deletions

View file

@ -1,6 +1,6 @@
{
"reportAny": {
"limit": 27487
"limit": 26879
},
"reportArgumentType": {
"limit": 2626
@ -24,7 +24,7 @@
"limit": 19
},
"reportExplicitAny": {
"limit": 8791
"limit": 8733
},
"reportFunctionMemberAccess": {
"limit": 7
@ -57,7 +57,7 @@
"limit": 5835
},
"reportMissingTypeArgument": {
"limit": 15779
"limit": 15757
},
"reportMissingTypeStubs": {
"limit": 40
@ -99,19 +99,19 @@
"limit": 0
},
"reportUnknownArgumentType": {
"limit": 45056
"limit": 45036
},
"reportUnknownLambdaType": {
"limit": 113
},
"reportUnknownMemberType": {
"limit": 39757
"limit": 39721
},
"reportUnknownParameterType": {
"limit": 20206
"limit": 20204
},
"reportUnknownVariableType": {
"limit": 31257
"limit": 31199
},
"reportUnnecessaryCast": {
"limit": 122

View file

@ -5238,6 +5238,8 @@ async def _fetch_user_team_objects(
teams: Final = await _prisma_table(TeamRepository(prisma_client)).find_many(
where={"team_id": {"in": complete_user_info.teams}}
)
if not teams:
return []
return [LiteLLM_TeamTable.model_validate(team.model_dump()) for team in teams]

View file

@ -103,6 +103,10 @@ class PrismaTableActions(Protocol):
async def count(self, *, where: Mapping[str, object] | None = None) -> int: ...
class JWTKeyMappingRecord(Protocol):
token: str
class ReadOnlyTable(Protocol):
async def find_many(self, *, where: Mapping[str, object]) -> Sequence[PrismaRecord]: ...

View file

@ -10,7 +10,7 @@ methods; richer repositories live in their own modules.
from collections.abc import Mapping, Sequence
from typing import Any, Final, Generic, TypeVar
from pydantic import BaseModel, TypeAdapter
from pydantic import BaseModel
from litellm.models.access_group import LiteLLM_AccessGroupTable
from litellm.models.end_user import LiteLLM_EndUserTable
@ -19,17 +19,17 @@ from litellm.models.team_membership import LiteLLM_TeamMembership
from litellm.proxy.common_utils.config_sync_pubsub import wrap_table_actions_for_config_sync
from litellm.repositories.prisma_protocols import (
DailyToolSpendTable,
JWTKeyMappingRecord,
MemoryTable,
PrismaTableActions,
SpendLogUsageRecord,
SpendLogUsageTable,
TableActions,
ToolIndexTable,
)
ModelT = TypeVar("ModelT", bound=BaseModel)
_TOKEN_ADAPTER: Final = TypeAdapter(str)
class PrismaTableRepository:
"""Base for repositories that expose a single Prisma table."""
@ -167,16 +167,21 @@ class InvitationLinkRepository(PrismaTableRepository):
class JWTKeyMappingRepository(PrismaTableRepository):
table_name = "litellm_jwtkeymapping"
@property
def rows(self) -> TableActions[JWTKeyMappingRecord]:
rows: Final[TableActions[JWTKeyMappingRecord]] = self.table
return rows
async def find_active_token(self, *, jwt_claim_name: str, jwt_claim_value: str) -> str | None:
"""Return the key token mapped to an active JWT claim pair."""
record: Final = await self.typed_table.find_first(
record: Final = await self.rows.find_first(
where={
"jwt_claim_name": jwt_claim_name,
"jwt_claim_value": jwt_claim_value,
"is_active": True,
}
)
return None if record is None else _TOKEN_ADAPTER.validate_python(record.dict()["token"])
return None if record is None else record.token
class ManagedFileRepository(PrismaTableRepository):

View file

@ -12,7 +12,7 @@
"limit": 2031
},
"ANN202": {
"limit": 864
"limit": 862
},
"ANN204": {
"limit": 713
@ -24,7 +24,7 @@
"limit": 133
},
"ANN401": {
"limit": 1544
"limit": 1514
},
"ASYNC230": {
"limit": 11
@ -57,7 +57,7 @@
"limit": 3
},
"BLE001": {
"limit": 2924
"limit": 2922
},
"C401": {
"limit": 8
@ -192,7 +192,7 @@
"limit": 0
},
"S110": {
"limit": 218
"limit": 216
},
"S112": {
"limit": 22
@ -234,7 +234,7 @@
"limit": 5
},
"TID251": {
"limit": 1235
"limit": 1231
},
"TRY002": {
"limit": 528

View file

@ -1,9 +1,9 @@
{
"LIT001": {
"limit": 23142
"limit": 23128
},
"LIT002": {
"limit": 27156
"limit": 27111
},
"LIT003": {
"limit": 269
@ -15,7 +15,7 @@
"limit": 0
},
"LIT006": {
"limit": 1086
"limit": 1084
},
"LIT007": {
"limit": 0
@ -27,9 +27,9 @@
"limit": 0
},
"LIT010": {
"limit": 16738
"limit": 16692
},
"LIT011": {
"limit": 5598
"limit": 5594
}
}