Skip to content

fix(ui): resolve tab slug against the last base-segment match - #34628

Open
ryan-crabbe-berri wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_tab_routing_server_root_fix
Open

fix(ui): resolve tab slug against the last base-segment match#34628
ryan-crabbe-berri wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_tab_routing_server_root_fix

Conversation

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Nested tab routes redirect-loop when SERVER_ROOT_PATH repeats a route segment name

How it solves it:

  • Match the last occurrence of the route base segment, not the first

Relevant issues

Linear ticket

Pre-Submission checklist

  • 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 received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Unit-level fix; the regression test in src/utils/tabRoutes.test.ts encodes the failing case. To see it against a live proxy, start the proxy with SERVER_ROOT_PATH=/logs, open http://localhost:4000/logs/ui/logs/audit/, and confirm the Audit Logs tab loads instead of looping back to the base path.

Type

🐛 Bug Fix

Changes

createTabRoutes.slugFromPathname (the shared tab-routing helper) parsed the active tab by matching the first occurrence of the route base segment in the pathname. When SERVER_ROOT_PATH is set to a value that repeats a route segment name, the server-root copy wins. Concretely, SERVER_ROOT_PATH=/logs mounts the UI at /logs/ui, so the Audit Logs tab lives at /logs/ui/logs/audit/; the parser matched the leading logs and returned ui instead of audit. The layout then treats ui as an unknown tab and hard-redirects to /logs/ui/logs/, which misparses the same way, producing a reload loop. Greptile flagged this as a P1 on the Logs per-tab-routing PR.

The fix matches the last occurrence of the base segment. The route base always comes after any server-root prefix in the path, and no tab slug equals the base, so the last match is always the real route base. This hardens every page that uses the shared helper (Caching, Cost Optimization, Router Settings, Logs) at once. legacyKeyForPathname already avoided this by stripping the uiBase() prefix first; this brings the tab parser in line. A regression test covers /logs/ui/logs/audit/ and /logs/ui/logs/.

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

createTabRoutes.slugFromPathname matched the first occurrence of the
route base segment. When SERVER_ROOT_PATH repeats that segment (e.g.
/logs mounts the UI at /logs/ui, so the audit tab is /logs/ui/logs/audit/),
it read the server-root copy and returned the wrong segment, which the
layout treats as an unknown tab and hard-redirects to a path that
misparses the same way, causing a reload loop. Match the last occurrence
instead: the route base always follows any server-root prefix, and no tab
slug equals the base, so the last match is always the real route base.
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Updates the shared dashboard tab-routing helper to resolve slugs from the last matching base segment, with regression tests covering repeated route segments in server-root-prefixed paths.

Confidence Score: 5/5

The PR appears safe to merge because the shared route parser now handles repeated server-root segments without regressing current tab-route shapes.

Current route definitions do not use tab slugs equal to their base segment, and the added tests directly cover the repeated-prefix paths that previously selected the wrong slug.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/utils/tabRoutes.ts Uses the last base-segment occurrence so server-root prefixes that repeat the route name no longer produce an incorrect tab slug.
ui/litellm-dashboard/src/utils/tabRoutes.test.ts Adds focused regression coverage for repeated base segments on both a named tab path and the route base path.

Reviews (1): Last reviewed commit: "fix(ui): resolve tab slug against the la..." | Re-trigger Greptile

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.

1 participant