Skip to content

fix: accept custom_body in URL-based create_pass_through_route endpoint_func#23412

Merged
krrishdholakia merged 1 commit intoBerriAI:mainfrom
joereyna:fix/pass-through-endpoint-custom-body
Mar 12, 2026
Merged

fix: accept custom_body in URL-based create_pass_through_route endpoint_func#23412
krrishdholakia merged 1 commit intoBerriAI:mainfrom
joereyna:fix/pass-through-endpoint-custom-body

Conversation

@joereyna
Copy link
Collaborator

Summary

  • create_pass_through_route has two endpoint_func implementations: one for adapter-based targets and one for URL-based targets
  • The adapter-based endpoint_func correctly accepts custom_body in its signature
  • The URL-based endpoint_func (the except branch) was missing custom_body, causing a TypeError when callers like bedrock_proxy_route pass custom_body=data
  • Fix: add custom_body: Optional[dict] = None to the URL-based endpoint_func signature and give it precedence over the request-parsed body

Test plan

  • test (proxy-misc)test_create_pass_through_route_custom_body_url_target passes

@vercel
Copy link

vercel bot commented Mar 12, 2026

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

Project Deployment Actions Updated (UTC)
litellm Error Error Mar 12, 2026 2:13am

Request Review

@joereyna joereyna self-assigned this Mar 12, 2026
@joereyna joereyna changed the title fix: add custom_body param to URL-based endpoint_func in create_pass_through_route fix: accept custom_body in URL-based create_pass_through_route endpoint_func Mar 12, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 12, 2026

Greptile Summary

This PR fixes a TypeError: endpoint_func() got an unexpected keyword argument 'custom_body' that occurred when bedrock_proxy_route (and similar callers) called the URL-based endpoint_func returned by create_pass_through_route with custom_body=data. The adapter-based endpoint_func already accepted this parameter; the URL-based one (the except branch) was missing it.

Key changes:

  • Added custom_body: Optional[dict] = None to the URL-based endpoint_func signature, matching the adapter-based one.
  • Implemented a simple precedence rule: if the caller supplies custom_body, it is used directly; otherwise, the body parsed from the raw request (custom_body_data) is used as a fallback, preserving existing behavior.
  • The accompanying mock tests (test_create_pass_through_route_custom_body_url_target and test_create_pass_through_route_no_custom_body_falls_back) were already merged into main via PR fix: add custom_body parameter to endpoint_func in create_pass_through_route #20849 and cover both the new precedence path and the fallback path.

Note: This is a re-application of the identical fix from PR #20849 (ab4b6197e), which appears to have been lost from the base branch of this PR due to a divergent merge history.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted bug fix with no backward-incompatible changes and full mock test coverage.
  • The change is a two-line addition (parameter + precedence branch) that strictly extends the existing signature, does not alter the fallback path, and directly mirrors the already-working adapter-based implementation. The existing test suite in main already validates both the new and the fallback behavior.
  • No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/pass_through_endpoints/pass_through_endpoints.py Adds custom_body: Optional[dict] = None to the URL-based endpoint_func in create_pass_through_route, with correct precedence over request-parsed body; fixes the TypeError raised when bedrock_proxy_route passes custom_body=data.

Sequence Diagram

sequenceDiagram
    participant Client
    participant bedrock_proxy_route
    participant create_pass_through_route
    participant endpoint_func (URL-based)
    participant _parse_request_data_by_content_type
    participant pass_through_request

    Client->>bedrock_proxy_route: POST /bedrock/{endpoint}
    bedrock_proxy_route->>bedrock_proxy_route: data = await request.json()
    bedrock_proxy_route->>bedrock_proxy_route: SigV4-sign request body
    bedrock_proxy_route->>create_pass_through_route: create_pass_through_route(endpoint, target, ...)
    create_pass_through_route-->>bedrock_proxy_route: endpoint_func (URL-based)
    bedrock_proxy_route->>endpoint_func (URL-based): await endpoint_func(..., custom_body=data)
    Note over endpoint_func (URL-based): custom_body param now accepted ✅ (was TypeError before fix)
    endpoint_func (URL-based)->>_parse_request_data_by_content_type: parse request (for query_params, etc.)
    _parse_request_data_by_content_type-->>endpoint_func (URL-based): query_params_data, custom_body_data, ...
    Note over endpoint_func (URL-based): custom_body != None → use caller-supplied body (takes precedence)
    endpoint_func (URL-based)->>pass_through_request: pass_through_request(..., custom_body=data)
    pass_through_request-->>Client: Forwarded response
Loading

Last reviewed commit: 8392967

@krrishdholakia krrishdholakia merged commit 483a605 into BerriAI:main Mar 12, 2026
28 of 37 checks passed
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