fix(proxy): tolerate a SpendLogsPayload without total_tokens

Reading payload["total_tokens"] unconditionally aborted _batch_database_updates
with a KeyError when a (test or partial) payload omits the key, dropping the
rest of the batch. Guard the typed index with a membership check so a missing
count falls back to 0, staying tolerant like the old .get while keeping the
read type-clean.
This commit is contained in:
Srivatsa03 2026-10-11 22:40:10 -05:00
parent fbda977c5e
commit 4eeb70009a

View file

@ -1066,7 +1066,7 @@ class DBSpendUpdateWriter:
team_id=team_id,
user_id=user_id,
prisma_client=prisma_client,
tokens=payload["total_tokens"],
tokens=payload["total_tokens"] if "total_tokens" in payload else 0,
)
except Exception:
verbose_proxy_logger.debug(