fix(ui): resolve tab slug against the last base-segment match - #34628
Open
ryan-crabbe-berri wants to merge 1 commit into
Open
fix(ui): resolve tab slug against the last base-segment match#34628ryan-crabbe-berri wants to merge 1 commit into
ryan-crabbe-berri wants to merge 1 commit into
Conversation
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.
5 tasks
Contributor
Greptile SummaryUpdates 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/5The 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.
|
| 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
Merged
5 tasks
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
Screenshots / Proof of Fix
Unit-level fix; the regression test in
src/utils/tabRoutes.test.tsencodes the failing case. To see it against a live proxy, start the proxy withSERVER_ROOT_PATH=/logs, openhttp://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. WhenSERVER_ROOT_PATHis set to a value that repeats a route segment name, the server-root copy wins. Concretely,SERVER_ROOT_PATH=/logsmounts the UI at/logs/ui, so the Audit Logs tab lives at/logs/ui/logs/audit/; the parser matched the leadinglogsand returneduiinstead ofaudit. The layout then treatsuias 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.
legacyKeyForPathnamealready avoided this by stripping theuiBase()prefix first; this brings the tab parser in line. A regression test covers/logs/ui/logs/audit/and/logs/ui/logs/.Final Attestation