Skip to content

fix: apply server root path to mapped passthrough route matching#22310

Open
umut-polat wants to merge 1 commit intoBerriAI:mainfrom
umut-polat:fix/server-root-path-passthrough
Open

fix: apply server root path to mapped passthrough route matching#22310
umut-polat wants to merge 1 commit intoBerriAI:mainfrom
umut-polat:fix/server-root-path-passthrough

Conversation

@umut-polat
Copy link

mapped passthrough routes (vertex_ai, bedrock, etc) were compared against the raw request path without prepending SERVER_ROOT_PATH. db-registered routes already used _build_full_path_with_root for this — the mapped routes branch was missed.

when a reverse proxy forwards /litellm/vertex_ai/... and SERVER_ROOT_PATH=/litellm, the route check fell through because it compared /litellm/vertex_ai/... against bare /vertex_ai.

one-line fix: run _build_full_path_with_root on each mapped route before the startswith check — same pattern already used 15 lines below for db routes.

test added covering prefixed and bare routes with a custom root.

fixes #22272

@vercel
Copy link

vercel bot commented Feb 27, 2026

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 27, 2026 10:33pm

Request Review

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 27, 2026

Greptile Summary

This PR fixes a bug where mapped pass-through routes (e.g., /vertex_ai, /bedrock) failed to match incoming requests when SERVER_ROOT_PATH is set to a non-root value (e.g., /litellm). The route check compared the prefixed request path /litellm/vertex_ai/... against the bare route /vertex_ai, causing a mismatch.

  • Applies _build_full_path_with_root() to each mapped route before the startswith check in is_registered_pass_through_route(), matching the existing pattern used for DB-registered routes
  • Adds a regression test that verifies both prefixed and bare route matching behavior with a custom SERVER_ROOT_PATH
  • The fix is minimal (one line), well-scoped, and consistent with the existing codebase pattern

Confidence Score: 5/5

  • This PR is safe to merge — it's a minimal, well-tested one-line fix that follows an existing pattern.
  • The change is a single line that applies the same _build_full_path_with_root() helper already used 15 lines below for DB-registered routes. The fix is consistent with established patterns, the test covers the regression scenario with mocks (no network calls), and the scope is extremely narrow — only the mapped routes branch of is_registered_pass_through_route() is affected.
  • No files require special attention

Important Files Changed

Filename Overview
litellm/proxy/pass_through_endpoints/pass_through_endpoints.py One-line fix applies _build_full_path_with_root to mapped pass-through routes, matching the pattern already used for DB-registered routes 15 lines below. Correct and consistent.
tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py Regression test verifies that mapped routes (vertex_ai, bedrock) match when SERVER_ROOT_PATH is set. Uses mocks only — no real network calls. Test covers both prefixed and bare routes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Incoming request<br>/litellm/vertex_ai/v1/projects/foo"] --> B["is_registered_pass_through_route(route)"]
    B --> C{"Check mapped routes<br>(vertex_ai, bedrock, etc.)"}
    C -->|"Before fix"| D["Compare: /litellm/vertex_ai/...<br>startswith /vertex_ai ❌"]
    D --> E["Falls through → 404"]
    C -->|"After fix"| F["_build_full_path_with_root(/vertex_ai)<br>→ /litellm/vertex_ai"]
    F --> G["Compare: /litellm/vertex_ai/...<br>startswith /litellm/vertex_ai ✅"]
    G --> H["Return True"]
    B --> I{"Check DB-registered routes<br>(already used _build_full_path_with_root)"}
    I --> J["Return True/False"]
Loading

Last reviewed commit: 9712843

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

mapped passthrough routes (vertex_ai, bedrock, etc) were compared
against the raw request path without prepending SERVER_ROOT_PATH.
db-registered routes already used _build_full_path_with_root for this
but the mapped routes branch was missed.

fixes BerriAI#22272
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]: Built-in LLM Passthrough Routes Fail with SERVER_ROOT_PATH

2 participants