fix(ui): keep team role and budget when the team ID is blank#34608
Open
yuneng-berri wants to merge 1 commit into
Open
fix(ui): keep team role and budget when the team ID is blank#34608yuneng-berri wants to merge 1 commit into
yuneng-berri wants to merge 1 commit into
Conversation
normalizeTeams guarded the object branch on the truthiness of team.team_id, so a row with an empty ID fell through to the reset branch that discards user_role and max_budget_in_team. Setting a role before typing an ID showed the row snapping back to "user", and the next edit to that row dropped whatever had been set before it. Guard on the shape of the entry instead.
Contributor
Greptile SummaryThis PR updates team normalization to preserve role and budget fields when a team has a blank ID
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified The revised guard handles the supported string and structured-object team representations correctly, and the added tests exercise both loaded settings and sequential edits before saving
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/app/(dashboard)/users/_components/DefaultUserSettings.tsx | The normalization guard correctly recognizes structured team entries with blank IDs while retaining their role and budget |
| ui/litellm-dashboard/src/app/(dashboard)/users/_components/DefaultUserSettings.test.tsx | Focused regression tests cover initial display, role retention, sequential edits, and the resulting save payload |
Reviews (1): Last reviewed commit: "fix(ui): keep team role and budget when ..." | Re-trigger Greptile
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.
TLDR
Problem this solves:
How it solves it:
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Steps to reproduce by hand, with the Admin UI dev server on :3000 pointed at a proxy on :4000:
Before (b9b27c2): the dropdown snaps back to "User" as soon as it re-renders
After (7a718d1): the dropdown stays on Admin
Before (b9b27c2): the budget you just typed is gone from the row
After (7a718d1): both the budget and the role survive, and "Save Changes" sends them
Type
🐛 Bug Fix
Changes
normalizeTeamsguarded its object branch on the truthiness ofteam.team_id, so any entry whose ID is an empty string fell through to the branch that returns a bare{ team_id: "", user_role: "user" }, discardinguser_roleandmax_budget_in_teamThat normalized copy feeds both the rendered row and
updateTeam, which is why the symptom shows up twice: the role dropdown re-renders as "User" even though the edited value holds "admin", and becauseupdateTeamspreads the normalized copy, the next edit to that row also wipes whatever was set before it. It bites on load too, since a team saved with a blank ID comes back with its role resetThe guard now tests the shape of the entry (
typeof team === "object" && team !== null && "team_id" in team) instead of the value, so a blank ID keeps its siblings. The bug predates the shadcn migration of this component and is unrelated to itThree tests in the mapped
DefaultUserSettings.test.tsxcover it: the role stays selected with a blank ID, a stored team with a blank ID keeps its role and budget on load, and the save payload carries both fields after two sequential edits. Reverting the guard fails all three; droppingmax_budget_in_teamor theuser_rolefallback each fails twoFinal Attestation