Skip to content

fix(proxy): add /prompts/list to self_managed_routes (fixes 401 for internal_user)#24311

Open
xykong wants to merge 1 commit intoBerriAI:mainfrom
xykong:fix/prompts-list-self-managed-routes
Open

fix(proxy): add /prompts/list to self_managed_routes (fixes 401 for internal_user)#24311
xykong wants to merge 1 commit intoBerriAI:mainfrom
xykong:fix/prompts-list-self-managed-routes

Conversation

@xykong
Copy link
Contributor

@xykong xykong commented Mar 21, 2026

Summary

Fixes a one-character naming mismatch that causes GET /prompts/list to return 401 Unauthorized for internal_user and other non-admin roles.

Fixes #24307

Root Cause

self_managed_routes contained "/prompt/list" (singular), but the actual endpoint is registered as @router.get("/prompts/list") (plural) in litellm/proxy/prompts/prompt_endpoints.py.

Because the route isn't in the whitelist, the proxy's permission checker requires PROXY_ADMIN for any request to /prompts/list, causing a 401 for non-admin users.

Change

# litellm/proxy/_types.py
  "/prompt/list",
  "/prompt/info",
+ "/prompts/list",  # plural route alias — endpoint is @router.get("/prompts/list")

Testing

  • ✅ Verified: internal_user API key can now successfully call GET /prompts/list
  • ✅ No change to access control for other routes
  • ✅ Existing /prompt/list entry preserved for backward compatibility

Impact

  • Minimal: 1-line addition to a list constant
  • No breaking changes
  • Affected roles: internal_user, team, any non-PROXY_ADMIN role

The prompts endpoint is defined as @router.get('/prompts/list') (plural)
but self_managed_routes only contained '/prompt/list' (singular), causing
401 Unauthorized errors for internal_user and other non-admin roles.

Fixes BerriAI#24307
@vercel
Copy link

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Mar 21, 2026 6:37pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 21, 2026

Greptile Summary

This PR fixes a one-character typo (/prompt/list/prompts/list) in the self_managed_routes list in LiteLLMRoutes, which was causing GET /prompts/list to return 401 Unauthorized for non-admin roles like internal_user. The fix is correct and minimal — the actual endpoint is registered as @router.get("/prompts/list") in litellm/proxy/prompts/prompt_endpoints.py, so adding the plural form to the whitelist restores expected access.

  • Core fix is correct: /prompts/list is now in self_managed_routes, allowing non-admin users to reach the endpoint where the proxy delegates authorization to the endpoint itself.
  • Incidental whitespace change: Lines 660–661 (/prompt/list and /prompt/info) gained an extra leading space, making their indentation inconsistent (9 spaces vs 8 for the rest of the list).
  • Pre-existing stale entries: /prompt/list and /prompt/info (singular) have no matching @router.get registration in the codebase — worth confirming whether these are intentional legacy placeholders or candidates for cleanup.
  • No automated test added: The PR description notes manual verification, but a unit/integration test for the route-access check would protect against future regressions.

Confidence Score: 4/5

  • Safe to merge — the change is a minimal, targeted addition to a route whitelist with no behavioral risk to existing routes.
  • The fix is clearly correct and addresses the reported 401 regression. The only deductions are: a minor incidental indentation inconsistency introduced on the two surrounding lines, no accompanying automated test, and two pre-existing stale route entries (/prompt/list, /prompt/info) whose status is unconfirmed. None of these affect correctness or security.
  • No files require special attention; the single changed file is low-risk.

Important Files Changed

Filename Overview
litellm/proxy/_types.py Adds "/prompts/list" to self_managed_routes, correctly fixing the 401 for non-admin users; introduces a minor incidental indentation inconsistency on the two surrounding lines.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Incoming Request\nGET /prompts/list] --> B{RouteChecks\n.check_route_access}
    B -->|route in management_routes?| C[Allow - Admin Only]
    B -->|route in self_managed_routes?| D[Allow - Endpoint Manages Own Auth]
    B -->|neither| E[Require PROXY_ADMIN\n→ 401 for internal_user]
    D --> F[prompt_endpoints.py\nhandles authorization]

    style E fill:#f88,color:#000
    style D fill:#8f8,color:#000
    style F fill:#8f8,color:#000
Loading

Last reviewed commit: "fix(proxy): add /pro..."

Comment on lines +660 to +662
"/prompt/list",
"/prompt/info",
"/prompts/list", # plural route alias — endpoint is @router.get("/prompts/list")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Incidental indentation inconsistency

Lines 660 and 661 were modified to have an extra leading space (9 spaces) while all other entries in self_managed_routes use 8 spaces. This is an unintentional whitespace change that breaks the list's consistent formatting.

Suggested change
"/prompt/list",
"/prompt/info",
"/prompts/list", # plural route alias — endpoint is @router.get("/prompts/list")
"/prompt/list",
"/prompt/info",
"/prompts/list", # plural route alias — endpoint is @router.get("/prompts/list")

Comment on lines +660 to +661
"/prompt/list",
"/prompt/info",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Potentially stale route entries

"/prompt/list" and "/prompt/info" (singular) appear in self_managed_routes, but no corresponding @router.get("/prompt/list") or @router.get("/prompt/info") endpoint exists anywhere in litellm/proxy/. These entries appear to be dead/stale and may have been pre-migration placeholders.

While this is pre-existing and not introduced by this PR, it's worth confirming whether these should be cleaned up or are intentionally kept for backward compatibility with an older routing scheme.

@codspeed-hq
Copy link
Contributor

codspeed-hq bot commented Mar 21, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing xykong:fix/prompts-list-self-managed-routes (4fa9a53) with main (b64b0d4)

Open in CodSpeed

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.

[Bug]: /prompts/list returns 401 for internal_user — route missing from self_managed_routes

1 participant