Skip to content

fix(ui): use sanitizeNumeric for team_member_budget in team edit form - #23505

Merged
RheagalFire merged 2 commits into
BerriAI:litellm_oss_staging_03_13_2026from
michelligabriele:fix/team-edit-ui-budget-zero
Mar 13, 2026
Merged

fix(ui): use sanitizeNumeric for team_member_budget in team edit form#23505
RheagalFire merged 2 commits into
BerriAI:litellm_oss_staging_03_13_2026from
michelligabriele:fix/team-edit-ui-budget-zero

Conversation

@michelligabriele

Copy link
Copy Markdown
Collaborator

The team edit form (TeamInfo.tsx) used Number() to convert the team_member_budget field value, which silently converts null/undefined/"" to 0. When an admin edits a team for any reason without touching the budget field, this sends team_member_budget=0 to the backend, creating a shared budget row with max_budget=0.0 that blocks all team members.

Use sanitizeNumeric (already used for tpm_limit, rpm_limit, soft_budget in the same form) which correctly returns null for empty/null/undefined values, preventing accidental zero-budget creation.

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🐛 Bug Fix

Changes

  • ui/litellm-dashboard/src/components/team/TeamInfo.tsx: Changed Number(values.team_member_budget) to sanitizeNumeric(values.team_member_budget) in the team edit form handler. sanitizeNumeric is already defined and used for tpm_limit, rpm_limit, and soft_budget in the same function — it was just missing for team_member_budget.

  • tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py: Added 3 tests for TeamMemberBudgetHandler.should_create_budget():

    • test_should_create_budget_with_none_values — returns False when all params are None
    • test_should_create_budget_with_zero_budget — returns True for explicit 0 (valid use case via API)
    • test_should_create_budget_with_valid_values — returns True when any param is provided

emerzon and others added 2 commits March 12, 2026 17:48
The team edit form (TeamInfo.tsx) used Number() to convert the
team_member_budget field value, which silently converts null/undefined/""
to 0. When an admin edits a team for any reason without touching the
budget field, this sends team_member_budget=0 to the backend, creating a
shared budget row with max_budget=0.0 that blocks all team members.

Use sanitizeNumeric (already used for tpm_limit, rpm_limit, soft_budget
in the same form) which correctly returns null for empty/null/undefined
values, preventing accidental zero-budget creation.
@vercel

vercel Bot commented Mar 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Mar 13, 2026 1:26am

Request Review

@greptile-apps

greptile-apps Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a UI bug in TeamInfo.tsx where editing a team without touching the team_member_budget field would silently send team_member_budget=0 to the backend (due to Number(null/undefined/"") evaluating to 0), inadvertently creating a shared budget row with max_budget=0.0 that blocks all team members. The fix replaces Number() with the already-present sanitizeNumeric() helper — consistent with how tpm_limit, rpm_limit, and soft_budget are handled in the same function — so that empty/null/undefined values correctly become null before reaching the API.

Key changes:

  • ui/litellm-dashboard/src/components/team/TeamInfo.tsx: Replace Number(values.team_member_budget) with sanitizeNumeric(values.team_member_budget) (single-line fix).
  • tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py: Add 3 unit tests verifying TeamMemberBudgetHandler.should_create_budget() correctly returns False for all-None inputs, True for an explicit 0, and True for any provided value.

Note: The added tests exercise existing backend logic rather than the new UI path — an end-to-end or snapshot test covering the form submission would strengthen coverage, but is not strictly required given the simplicity of the one-line change.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, isolated one-line UI fix backed by new unit tests, with zero risk of regressions.
  • The change is a single-line substitution of one function call for another that is already used for three sibling fields in the same handler. The sanitizeNumeric helper is local, well-understood, and correct. The added tests confirm existing backend behaviour. No backend, database, or API contract changes are made.
  • No files require special attention.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/components/team/TeamInfo.tsx Single-line fix replacing Number(values.team_member_budget) with sanitizeNumeric(values.team_member_budget), consistent with how tpm_limit, rpm_limit, and soft_budget are already handled in the same function. Prevents accidental zero-budget creation.
tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py Adds 3 pure unit tests for TeamMemberBudgetHandler.should_create_budget() covering None-all-params → False, explicit-zero → True, and any-valid-value → True. No real network calls; tests import the class directly.

Sequence Diagram

sequenceDiagram
    participant Admin as Admin (UI)
    participant Form as TeamInfo Form
    participant Handler as onFinish handler
    participant API as /team/update API
    participant DB as Database

    Admin->>Form: Edit team (leave budget field blank)
    Form->>Handler: values.team_member_budget = null / ""

    Note over Handler: BEFORE fix
    Handler->>Handler: Number(null) → 0
    Handler->>API: team_member_budget = 0
    API->>DB: CREATE BudgetRow(max_budget=0.0) ❌

    Note over Handler: AFTER fix
    Handler->>Handler: sanitizeNumeric(null) → null
    Handler->>API: team_member_budget = null
    API->>API: should_create_budget(None) → False
    API->>DB: No budget row created ✅
Loading

Last reviewed commit: 897b863

@RheagalFire
RheagalFire changed the base branch from main to litellm_oss_staging_03_13_2026 March 13, 2026 19:06
@RheagalFire
RheagalFire merged commit 239edc4 into BerriAI:litellm_oss_staging_03_13_2026 Mar 13, 2026
15 of 37 checks passed
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