Repository navigation
fix(ui): persist budget window deletion on virtual keys - #31107
ryan-crabbe-berri merged 3 commits into
Conversation
Greptile SummaryThis PR fixes a bug where deleting the last budget window on a virtual key did not persist because the UI sent
Confidence Score: 5/5Safe to merge — the change is minimal, isolated to the budget-window submission path, and all three edge cases are covered by new regression tests. The fix touches a single code path in the form submit handler. The before/after behavior is clearly documented in the PR, proven against a live proxy, and covered by three targeted tests that would catch regressions in any of the three submission scenarios (clear, preserve, incomplete). No unrelated code is changed. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/templates/key_edit_view.tsx | One-line logic fix: sends [] instead of undefined when all budget windows are removed, so the backend receives an explicit clear signal. All three cases (valid windows, empty list, incomplete entries) are handled correctly. |
| ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx | Three new regression tests added: delete-last-window sends [], untouched windows are resent, and an incomplete entry omits budget_limits. Tests are well-structured and cover the key scenarios. |
Reviews (3): Last reviewed commit: "fix(ui): persist budget window deletion ..." | Re-trigger Greptile
Greptile SummaryThis PR fixes a budget window deletion bug in the virtual key edit form where clearing all windows had no effect on the backend. When
Confidence Score: 4/5Safe to merge; the change is a one-line frontend fix with no backend modifications and no changes to existing tests. The fix is minimal and directly addresses the root cause: sending No files require special attention; both changed files are straightforward and well-scoped.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/templates/key_edit_view.tsx | One-line fix: sends budget_limits: [] instead of undefined when all windows are deleted, ensuring the backend receives an explicit clear signal rather than omitting the field entirely. |
| ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx | Adds two new mock tests: one verifying that deleting the last budget window submits [], and one ensuring existing untouched windows are still resent correctly. Both are mock-only and satisfy the no-real-network-calls policy. |
Reviews (2): Last reviewed commit: "fix(ui): persist budget window deletion ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Deleting every budget window from a virtual key looked like it saved but reverted on reload, while editing a window persisted. The key edit form set budget_limits to undefined once the window list was emptied, and JSON.stringify drops undefined keys, so /key/update received no budget_limits field at all and model_dump(exclude_unset=True) skipped the existing clear-on-empty branch. Sending [] instead lets the backend store JSON null and clear the stored windows, matching how it already treats an explicit empty list Resolves LIT-3742
cc90dc0 to
e57b5a7
Compare
|
Pushed a follow-up: only send |
…itellm_fix_budget_window_delete
…itellm_fix_budget_window_delete
Relevant issues
Linear ticket
Resolves LIT-3742
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
make test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer review (5/5)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
CI (LiteLLM team)
Branch creation CI run
Link: https://github.com/BerriAI/litellm/pull/31107/checks
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Screenshots / Proof of Fix
Root cause: when every budget window is removed in the virtual key edit form, the form set
budget_limitstoundefined.JSON.stringifydropsundefinedkeys, so/key/updatenever received abudget_limitsfield,model_dump(exclude_unset=True)excluded it, and the backend branch that clears the stored windows on an empty value never ran. Editing a window kept working because a non-empty list is always sent. The one-line fix sends[]instead ofundefined, which the backend already maps to "clear the stored windows"; seekey_management_endpoints.pywherebudget_limits == []is stored as JSON null.The contrast below was captured against a live proxy backed by Postgres. The first update reproduces what today's UI sends on a delete (no



budget_limitsfield); the second is what the patched UI sends.Edit and partial-delete still behave correctly (this is the "editing persists" half of the report):
To reproduce the end-user flow in the UI on this branch: open http://localhost:4000/ui/?page=api-keys, edit a key that has a budget window under "Budget Windows", click the red "✕" next to the only window, click "Save Changes", reopen the key, and the window stays gone. Before this change it reappears.
Type
🐛 Bug Fix
Changes
ui/litellm-dashboard/src/components/templates/key_edit_view.tsxnow submitsbudget_limits: []when the user has removed every window, so a delete is sent to the backend as an explicit clear. When valid windows remain it submits those, and when entries remain but are still incomplete (a window whosemax_budgethas not been filled in yet) it omits the field so the saved windows are left untouched rather than wiped; that last case preserves the prior behavior and avoids a half-typed window clearing existing budgets on save. Added three regression tests inkey_edit_view.test.tsx: deleting the last window submits[](fails on the old code), leaving existing windows untouched still resubmits them so editing is not regressed, and an incomplete window omitsbudget_limitsrather than clearing.