Repository navigation
fix(ui): fix Router Settings Loadbalancing tab save (LIT-4057) - #31735
yuneng-berri merged 5 commits into
Conversation
The Loadbalancing tab rendered routing_groups as a generic text input and sent its array value back as the JSON string "[]", which fails Pydantic list validation on POST /config/update and returns 422. routing_groups has its own dedicated Routing Groups tab, so this tab must neither render nor write it; exclude it the same way retry_policy and model_group_retry_policy are excluded for the Model Retry Settings tab. The save was also fire-and-forget: setCallbacksCall was not awaited, so the rejected promise escaped the try/catch and the success toast fired unconditionally, showing success even when the backend rejected the change. Await the call, gate the success toast on resolution, and surface the error.
Merging this PR will improve performance by 11.15%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_completion_simple_message |
4.6 ms | 4.1 ms | +11.15% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing litellm_lit_4057_router_settings_routing_groups_save (4f41a9e) with litellm_internal_staging (be4d0d8)
Greptile SummaryThis PR fixes two independent bugs on the Router Settings → Loadbalancing tab:
Confidence Score: 5/5The change is safe to merge: it is a minimal, targeted fix with no impact on backend code or request-path logic. Both fixes are correct and well-contained. The save handler now properly awaits the network call and gates the toast on success, and No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/router_settings/index.tsx | Two targeted fixes: handleSaveChanges is now async with setCallbacksCall awaited and the success toast moved inside the try block; routing_groups added to tabOwnedKeys so it is excluded from the save payload. |
| ui/litellm-dashboard/src/components/router_settings/ReliabilityRetriesSection.tsx | Adds routing_groups to the render-time filter blocklist alongside retry_policy / model_group_retry_policy; also removes the now-unused value destructure from the filter callback. |
| ui/litellm-dashboard/src/components/router_settings/index.test.tsx | Adds two regression tests: one verifying routing_groups is absent from the save payload and not rendered, and one verifying that a rejected save shows an error notification and no false-success toast. |
| ui/litellm-dashboard/e2e_tests/tests/settings/routerSettings.spec.ts | Adds a typed Playwright e2e suite that seeds routing_groups: [], changes num_retries, clicks Save, asserts the network response is 200 (not 422), and verifies the value persists across a reload. |
Reviews (4): Last reviewed commit: "test(ui): drop the e2e typecheck CI gate..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Address Greptile P2: the routing_groups test read setCallbacksCall.mock.calls[0][1] immediately after the now-async save handler, so any latency in the mock would throw an opaque TypeError instead of a clean assertion failure. Assert through toHaveBeenCalledWith inside waitFor with expect.not.objectContaining, dropping the index access and the cast. Also drop the ticket id from the test names.
|
@greptileai re review |
…057) Drives the real save flow against a live proxy: seeds a present routing_groups array (the LIT-4057 trigger) via the typed /config/update contract, changes num_retries on the Loadbalancing tab, and asserts the POST returns 200 instead of 422, the success toast appears, and the value still shows after a reload (the ticket's "refresh shows old values" symptom). The round-trip is typed against the OpenAPI-generated backend schema (ConfigYAML write, RouterSettingsResponse read) through a type-only import, so a backend contract drift fails the type check.
|
@greptileai re review |
Address an adversarial review of the Loadbalancing e2e: - The "typed against the backend schema" claim was hollow: nothing type-checked e2e_tests (the root tsconfig excludes it and no CI step runs tsc), so a contract drift would compile and run unchanged. Add e2e_tests/tsconfig.json, a typecheck:e2e script, and a CircleCI step so the schema typing actually gates. - The two describe blocks both mutate the proxy's shared router_settings, and the Loadbalancing save echoes the whole settings object, so they could clobber each other under local fullyParallel. Run the file serially. - patchRouterSettings swallowed a failed seed, which surfaced later as a misleading UI timeout. Assert the write succeeded, and rely on the server-side merge instead of echoing the whole settings object back (drops a cast and a GET). - Empty routing_groups already reproduces the bug, so drop the non-empty seed and its model coupling.
…he editor The e2e runs against the real proxy, so a contract drift already fails the test at runtime; tsc only checks the spec against schema.d.ts, a generated snapshot, so a backend change with a stale snapshot would pass tsc while the live test still catches it. The dedicated tsconfig + script + CI step were circular ceremony for that. Keep the zero-runtime-cost type-only import, which still catches mistakes in the editor, and make its comment honest about what enforces the contract.
2fb07ff to
4f41a9e
Compare
|
@greptileai re review |
Relevant issues
Linear ticket
Resolves LIT-4057
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewWhat this fixes
Saving on Admin UI -> Settings -> Router Settings -> Loadbalancing showed a success toast but the change was never persisted, and the network call returned 422
Two independent defects on that tab caused it. First, the tab renders every router setting that isn't on a small blocklist as a generic text input, and
routing_groupswas not on that list. Its array value wasJSON.stringify'd into the box and read back on save as the string"[]", which fails Pydantic list validation onPOST /config/updateand returns 422.routing_groupsalready has its own dedicated Routing Groups tab, exactly likeretry_policyandmodel_group_retry_policyhave the Model Retry Settings tab, so the Loadbalancing tab must neither render nor write it. Second, the save was fire-and-forget:setCallbacksCallwas not awaited, so the rejected promise escaped the surroundingtry/catchand the success toast fired unconditionally, reporting success even when the backend rejected the changeHow
routing_groupsis added to the sametabOwnedKeysexclusion that already dropsretry_policy/model_group_retry_policyfrom the save payload, and to the render blocklist inReliabilityRetriesSectionso it no longer shows as a JSON text box on this tab. The backend merge keeps the existingrouting_groupsvalue untouched because the field is simply absent from the request. The save handler now awaitssetCallbacksCall, fires the success toast only after it resolves, and surfaces backend errors throughNotificationsManager.fromBackendThe root cause is a class of bug: the tab renders an unpinned, data-driven field set and reconstructs types from a hand-maintained allowlist that drifts from the backend schema, which is how
routing_groupsslipped through after the earlierretry_policyfix. This PR is the minimal, targeted fix; the full rewrite of this tab to a typed react-query form with proper controls is tracked separately in LIT-4113, and the sibling General tab cleanup in LIT-4112Screenshots / Proof of Fix
This is a UI fix, so the proof is the save round-trip in the browser plus the API confirming persistence. Run an ordered set of steps against a live proxy on
localhost:4000with this branch's dashboard builthttp://localhost:4000/ui?page=router-settingsand select the Loadbalancing tabThe backend contract this fixes, for reference: a stringified array is rejected, a real array is accepted
The frontend e2e suite covers this end to end; run the Router Settings spec against the harness
Type
🐛 Bug Fix
Changes
Excluded
routing_groupsfrom the Loadbalancing tab's render blocklist and from thetabOwnedKeyssave exclusion so it is no longer serialized as the string"[]". Made the save handler awaitsetCallbacksCalland gate the success toast on resolution so backend failures surface as errors instead of a false success. Added regression tests covering both: the save payload never includesrouting_groups, the field is not rendered on this tab, and a failing save shows an error and no success toast. Added a typed Playwright e2e ine2e_tests/tests/settings/routerSettings.spec.tsthat seeds a presentrouting_groupsarray, changes a value on the Loadbalancing tab, and asserts the save returns 200 instead of 422 and persists across a reload, typing the round-trip against the generated backend schema for editor-level checking while the live test against the real proxy enforces the contract at runtime