Skip to content

fix(ui): fix Router Settings Loadbalancing tab save (LIT-4057) - #31735

Merged
yuneng-berri merged 5 commits into
litellm_internal_stagingfrom
litellm_lit_4057_router_settings_routing_groups_save
Jun 30, 2026
Merged

yuneng-berri merged 5 commits into
litellm_internal_stagingfrom
litellm_lit_4057_router_settings_routing_groups_save

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Resolves LIT-4057

Pre-Submission checklist

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

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • 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

What 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_groups was not on that list. Its array value was JSON.stringify'd into the box and read back on save as the string "[]", which fails Pydantic list validation on POST /config/update and returns 422. routing_groups already has its own dedicated Routing Groups tab, exactly like retry_policy and model_group_retry_policy have the Model Retry Settings tab, so the Loadbalancing tab must neither render nor write it. Second, the save was fire-and-forget: setCallbacksCall was not awaited, so the rejected promise escaped the surrounding try/catch and the success toast fired unconditionally, reporting success even when the backend rejected the change

How

routing_groups is added to the same tabOwnedKeys exclusion that already drops retry_policy / model_group_retry_policy from the save payload, and to the render blocklist in ReliabilityRetriesSection so it no longer shows as a JSON text box on this tab. The backend merge keeps the existing routing_groups value untouched because the field is simply absent from the request. The save handler now awaits setCallbacksCall, fires the success toast only after it resolves, and surfaces backend errors through NotificationsManager.fromBackend

The 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_groups slipped through after the earlier retry_policy fix. 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-4112

Screenshots / 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:4000 with this branch's dashboard built

  1. Start the proxy with the worktree dashboard so the UI reflects this branch
  2. Open http://localhost:4000/ui?page=router-settings and select the Loadbalancing tab
  3. Change a value, for example set Num Retries to 5, then click Save Changes
  4. Confirm the success toast appears and, after a full page refresh, the new value is still shown (before this fix the toast appeared but the value reverted)
  5. Confirm persistence through the API
curl -sS http://localhost:4000/router/settings -H "Authorization: Bearer sk-1234" \
  | jq '.current_values | {num_retries, routing_groups}'

The backend contract this fixes, for reference: a stringified array is rejected, a real array is accepted

# was being sent by the UI -> 422
curl -sS -i -X POST http://localhost:4000/config/update \
  -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" \
  -d '{"router_settings": {"routing_groups": "[]"}}' | head -1

# correct -> 200
curl -sS -X POST http://localhost:4000/config/update \
  -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" \
  -d '{"router_settings": {"num_retries": 5}}'

The frontend e2e suite covers this end to end; run the Router Settings spec against the harness

cd ui/litellm-dashboard/e2e_tests && npx playwright test tests/settings/routerSettings.spec.ts

Type

🐛 Bug Fix

Changes

Excluded routing_groups from the Loadbalancing tab's render blocklist and from the tabOwnedKeys save exclusion so it is no longer serialized as the string "[]". Made the save handler await setCallbacksCall and 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 includes routing_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 in e2e_tests/tests/settings/routerSettings.spec.ts that seeds a present routing_groups array, 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

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.
@codspeed

codspeed Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 11.15%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 29 untouched benchmarks

Performance Changes

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)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two independent bugs on the Router Settings → Loadbalancing tab: routing_groups was leaking into the save payload as the string "[]" (causing a 422), and the save was fire-and-forget so the success toast fired unconditionally even on backend rejection.

  • routing_groups is added to both the render-time filter in ReliabilityRetriesSection and the tabOwnedKeys exclusion set in handleSaveChanges, matching how retry_policy and model_group_retry_policy are already handled by their respective tabs.
  • handleSaveChanges is converted to async, setCallbacksCall is now awaited, and the success toast is moved inside the try block so backend failures surface through NotificationsManager.fromBackend instead of being silently swallowed.
  • Unit tests cover both regressions (payload exclusion and error surfacing); a typed Playwright e2e test seeds routing_groups: [] and asserts the full save round-trip returns 200 and persists across a reload.

Confidence Score: 5/5

The 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 routing_groups is consistently excluded from both render and save. The new unit and e2e tests directly cover the regressed scenarios.

No files require special attention.

Important Files Changed

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

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

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.
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@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.
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@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.
@ryan-crabbe-berri
ryan-crabbe-berri requested a review from a team June 30, 2026 19:08
…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.
@ryan-crabbe-berri
ryan-crabbe-berri force-pushed the litellm_lit_4057_router_settings_routing_groups_save branch from 2fb07ff to 4f41a9e Compare June 30, 2026 19:50
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@yuneng-berri
yuneng-berri merged commit 776b272 into litellm_internal_staging Jun 30, 2026
77 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_lit_4057_router_settings_routing_groups_save branch June 30, 2026 22:39
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.

2 participants