fix(proxy): LiteLLM_TeamMembership.litellm_budget_table missing default causes ValidationError → 401 (#28689) - #28699
Conversation
…m_budget_table In Pydantic v2, Optional[T] without a default is a *required* field. LiteLLM_TeamMembership.litellm_budget_table had no default, so when Prisma returns a membership row without a litellm_budget_table key (budget_id=null after /team/member_update), Pydantic raises ValidationError: Field required, making every subsequent auth check fail with a 401 for that user. Fix: give the field an explicit `= None` default. Closes BerriAI#28689
|
devteamaegis seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Greptile SummaryThis PR fixes a one-character omission — a missing
Confidence Score: 5/5Safe to merge — the change is minimal, correctly targeted, and fully covered by two new regression tests. The one-line fix aligns the field declaration with Pydantic v2 semantics and matches how all other optional fields on the same model are already declared. The regression tests directly exercise both the missing-key and explicit-null paths and confirm the fix works. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/_types.py | One-line fix: adds = None default to LiteLLM_TeamMembership.litellm_budget_table, resolving a Pydantic v2 ValidationError that was causing 401s when budget_id was nulled out. |
| tests/test_litellm/proxy/auth/test_team_member_budget.py | Two new regression tests added: one omitting litellm_budget_table entirely and one passing it as None explicitly; both are pure unit tests with no network calls. |
Reviews (1): Last reviewed commit: "fix(proxy): add missing default=None to ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Problem
Closes #28689.
LiteLLM_TeamMembership.litellm_budget_tablewas declared as:In Pydantic v2,
Optional[T]without a default value is a required field — it must be present in the input data; it does not default toNone.When a user's
budget_idis set tonullvia/team/member_update, the Prisma join returns a membership row with nolitellm_budget_tablekey. Pydantic then raises:This propagates through
common_checks→ every request from that user returns 401 Unauthorized.Fix
One-line change — give the field an explicit
= Nonedefault:Tests
Added two regression tests to
tests/test_litellm/proxy/auth/test_team_member_budget.py:test_team_membership_without_budget_table_deserializes— omitslitellm_budget_tableentirely (as Prisma would whenbudget_id=null); asserts model instantiates cleanly andsafe_get_team_member_*_limit()helpers returnNone.test_team_membership_explicit_none_budget_table— passeslitellm_budget_table=Noneexplicitly (JSONnullpath); same assertions.