Skip to content

fix(proxy): LiteLLM_TeamMembership.litellm_budget_table missing default causes ValidationError → 401 (#28689) - #28699

Closed
devteamaegis wants to merge 1 commit into
BerriAI:mainfrom
devteamaegis:fix/team-membership-budget-table-required-field
Closed

fix(proxy): LiteLLM_TeamMembership.litellm_budget_table missing default causes ValidationError → 401 (#28689)#28699
devteamaegis wants to merge 1 commit into
BerriAI:mainfrom
devteamaegis:fix/team-membership-budget-table-required-field

Conversation

@devteamaegis

Copy link
Copy Markdown

Problem

Closes #28689.

LiteLLM_TeamMembership.litellm_budget_table was declared as:

litellm_budget_table: Optional[Union[LiteLLM_BudgetTableFull, LiteLLM_BudgetTable]]

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 to None.

When a user's budget_id is set to null via /team/member_update, the Prisma join returns a membership row with no litellm_budget_table key. Pydantic then raises:

ValidationError: 1 validation error for LiteLLM_TeamMembership
litellm_budget_table
  Field required [type=missing, ...]

This propagates through common_checks → every request from that user returns 401 Unauthorized.

Fix

One-line change — give the field an explicit = None default:

litellm_budget_table: Optional[Union[LiteLLM_BudgetTableFull, LiteLLM_BudgetTable]] = None

Tests

Added two regression tests to tests/test_litellm/proxy/auth/test_team_member_budget.py:

  • test_team_membership_without_budget_table_deserializes — omits litellm_budget_table entirely (as Prisma would when budget_id=null); asserts model instantiates cleanly and safe_get_team_member_*_limit() helpers return None.
  • test_team_membership_explicit_none_budget_table — passes litellm_budget_table=None explicitly (JSON null path); same assertions.

…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
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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-apps

greptile-apps Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a one-character omission — a missing = None default on LiteLLM_TeamMembership.litellm_budget_table — that caused Pydantic v2 to treat the field as required, raising ValidationError and returning 401 for every request from users whose budget_id was nulled out.

  • litellm/proxy/_types.py: Adds = None default to litellm_budget_table; all other fields on the model already have explicit defaults, so this brings the field into line with the rest of the class.
  • tests/test_litellm/proxy/auth/test_team_member_budget.py: Adds two targeted regression tests — one that omits the key entirely (as Prisma would when budget_id=null) and one that passes None explicitly — both are pure unit tests with no network calls.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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

@codspeed-hq

codspeed-hq Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing devteamaegis:fix/team-membership-budget-table-required-field (197b0f4) with main (35f6961)

Open in CodSpeed

@codecov

codecov Bot commented May 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants