fix(proxy): add team_member_budget_duration to NewTeamRequest#23484
Merged
yuneng-jiang merged 2 commits intoBerriAI:mainfrom Mar 20, 2026
Merged
Conversation
NewTeamRequest was missing the team_member_budget_duration field, causing Pydantic to silently drop the value when creating a team via POST /team/new. The template budget row was created without budget_duration or budget_reset_at, so the ResetBudgetJob never found it and team member spend was never reset. Add the field to NewTeamRequest and pass it through to should_create_budget and create_team_member_budget_table in the new_team handler (matching the existing update_team path which already works correctly). Fixes BerriAI#16057
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes a bug where Changes:
The fix is minimal and surgical — it threads the missing field through the existing handler signatures that already supported it. The Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/_types.py | Added team_member_budget_duration: Optional[str] = None to NewTeamRequest, matching the field already present on UpdateTeamRequest. Correct and minimal change. |
| litellm/proxy/management_endpoints/team_endpoints.py | Passes data.team_member_budget_duration to should_create_budget and create_team_member_budget_table in the new_team handler — directly mirrors the already-working update_team path. The field is also cleaned up via the pre-existing _clean_team_member_fields before persisting the team record. |
| tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py | Two new unit tests: one verifies field is not silently dropped by Pydantic, the other verifies budget_duration is forwarded to new_budget. Both use only mocks — no real network calls — satisfying the test folder policy. |
Sequence Diagram
sequenceDiagram
participant Client
participant new_team as POST /team/new
participant Handler as TeamMemberBudgetHandler
participant BudgetEndpoint as budget_management_endpoints.new_budget
participant DB as Database
Client->>new_team: NewTeamRequest(team_member_budget_duration="30d", ...)
new_team->>Handler: should_create_budget(team_member_budget_duration="30d")
Handler-->>new_team: True
new_team->>Handler: create_team_member_budget_table(team_member_budget_duration="30d")
Handler->>BudgetEndpoint: new_budget(BudgetNewRequest(budget_duration="30d", ...))
BudgetEndpoint->>DB: INSERT LiteLLM_BudgetTable(budget_duration="30d", budget_reset_at=...)
DB-->>BudgetEndpoint: budget row
BudgetEndpoint-->>Handler: budget_id
Handler-->>new_team: data_json with metadata.team_member_budget_id
new_team->>DB: INSERT LiteLLM_TeamTable(...)
DB-->>new_team: team record
new_team-->>Client: 200 OK team response
Last reviewed commit: "Merge branch 'main' ..."
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NewTeamRequest was missing the team_member_budget_duration field, causing Pydantic to silently drop the value when creating a team via POST /team/new. The template budget row was created without budget_duration or budget_reset_at, so the ResetBudgetJob never found it and team member spend was never reset.
Add the field to NewTeamRequest and pass it through to should_create_budget and create_team_member_budget_table in the new_team handler (matching the existing update_team path which already works correctly).
Fixes #16057
Relevant issues
Fixes #16057
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🐛 Bug Fix
Changes
litellm/proxy/_types.py: Addedteam_member_budget_duration: Optional[str] = NonetoNewTeamRequest— the field was present onUpdateTeamRequestbut missing fromNewTeamRequest, causing Pydantic to silently drop it at team creation.litellm/proxy/management_endpoints/team_endpoints.py: Passdata.team_member_budget_durationtoTeamMemberBudgetHandler.should_create_budget()andTeamMemberBudgetHandler.create_team_member_budget_table()in thenew_teamhandler — matching the existingupdate_teamhandler which already passes it correctly.tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py: Added 2 tests:test_new_team_request_accepts_team_member_budget_duration— verifies the field is not silently droppedtest_create_team_member_budget_table_with_duration— verifiesbudget_durationis passed through to thenew_budgetcall, resulting in a budget row withbudget_durationandbudget_reset_atset