fix(proxy): satisfy type gates for team-attributed tag spend

DailyTagSpendTransaction.team_id is ReadOnly (LIT012), since nothing writes it
after the transaction is built.

The two payload.get("team_id") reads keep .get rather than indexing and carry
the file's existing reportUnknownMemberType suppression for TypedDict.get. The
caller swallows exceptions at debug level, so indexing would silently drop a
request's tag spend whenever a payload lacked team_id, instead of recording it
as unattributed.

LIT-8516
This commit is contained in:
Mrinal Chanshetty 2026-10-19 15:38:23 -07:00
parent 5cbe0eb02e
commit 9e2e2eb6dc
2 changed files with 5 additions and 3 deletions

View file

@ -5162,7 +5162,7 @@ class DailyTagSpendTransaction(BaseDailySpendTransaction):
# "" when the request had no team. Not required: entries queued by a pod running the
# previous release, or replayed from the Redis buffer across an upgrade, carry no such key,
# and the upsert reads a missing value as "".
team_id: NotRequired[str]
team_id: ReadOnly[NotRequired[str]]
class DailyAgentSpendTransaction(BaseDailySpendTransaction):

View file

@ -918,7 +918,7 @@ class DBSpendUpdateWriter:
model_group=base.get("model_group"),
endpoint=base.get("endpoint"),
mcp_namespaced_tool_name=base.get("mcp_namespaced_tool_name"),
team_id=payload.get("team_id") or "",
team_id=payload.get("team_id") or "", # pyright: ignore[reportUnknownMemberType] # TypedDict.get overloads carry Any defaults
targets=tuple(
DailyBaselineTarget(entity=entity, entity_id=identity)
for entity, values in bases
@ -3035,7 +3035,9 @@ class DBSpendUpdateWriter:
return
request_tags: Final = daily_spend_entity_ids(payload, "tag")
team_id: Final = payload.get("team_id") or ""
# .get, not indexing: the caller swallows exceptions at debug level, so a payload without
# team_id must still record its tag spend (as unattributed) rather than drop it silently.
team_id: Final = payload.get("team_id") or "" # pyright: ignore[reportUnknownMemberType] # TypedDict.get overloads carry Any defaults
for tag in request_tags:
if tag is None:
continue