Skip to content

fix: add custom_body parameter to endpoint_func in create_pass_through_route#20849

Merged
krrishdholakia merged 2 commits intoBerriAI:mainfrom
themavik:fix-bedrock-passthrough-custom-body
Feb 14, 2026
Merged

fix: add custom_body parameter to endpoint_func in create_pass_through_route#20849
krrishdholakia merged 2 commits intoBerriAI:mainfrom
themavik:fix-bedrock-passthrough-custom-body

Conversation

@themavik
Copy link
Contributor

Summary

Fixes #16999

The bedrock_proxy_route calls endpoint_func(custom_body=data) to pass a pre-parsed, SigV4-signed request body to the pass-through handler. However, the endpoint_func closure created by create_pass_through_route does not accept a custom_body keyword argument, causing:

TypeError: create_pass_through_route.<locals>.endpoint_func() got an unexpected keyword argument 'custom_body'

This crashes all Bedrock knowledge base retrieve requests going through the v1 passthrough.

Root Cause

create_pass_through_route defines two variants of endpoint_func:

  1. Adapter-based (when target is a CustomLogger)
  2. URL-based (when target is a URL string)

Neither accepts custom_body as a parameter. The bedrock proxy route at line 1050 passes custom_body=data as a keyword argument, which fails.

Fix

  • Add custom_body: Optional[dict] = None to both endpoint_func signatures.
  • In the URL-based path, when custom_body is provided by the caller, use it directly instead of re-parsing the body from the raw request. This is the correct behavior since the bedrock proxy has already parsed and signed the body.

Changes

  • litellm/proxy/pass_through_endpoints/pass_through_endpoints.py

Test Plan

  • Verify Bedrock knowledge base retrieve requests through the proxy no longer crash with TypeError.
  • Verify other pass-through endpoints (Vertex, Azure, etc.) are unaffected since they don't pass custom_body.
  • Verify that the URL-based endpoint still correctly parses the body from the request when custom_body is not provided.

…h_route

The bedrock_proxy_route calls `endpoint_func(custom_body=data)` to
pass a pre-parsed, SigV4-signed request body. However, the
`endpoint_func` closure created by `create_pass_through_route` does
not accept a `custom_body` keyword argument, causing:

    TypeError: endpoint_func() got an unexpected keyword argument 'custom_body'

Add `custom_body: Optional[dict] = None` to both `endpoint_func`
definitions (adapter-based and URL-based). In the URL-based path,
when `custom_body` is provided by the caller, use it instead of
re-parsing the body from the raw request.

Fixes #16999
@vercel
Copy link

vercel bot commented Feb 10, 2026

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 11, 2026 7:33am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 10, 2026

Greptile Overview

Greptile Summary

This PR fixes a runtime TypeError in the v1 Bedrock passthrough by updating the endpoint_func closures created by create_pass_through_route to accept a custom_body kwarg. In the URL-based passthrough path, it also prefers a caller-supplied body (e.g., Bedrock’s pre-parsed, SigV4-signed JSON) over the request-parsed body before calling pass_through_request.

The change fits into the proxy passthrough architecture by allowing higher-level routes (like bedrock_proxy_route) to inject a prepared body into the generic passthrough handler without re-parsing/mutating it inside create_pass_through_route.

Confidence Score: 4/5

  • Mostly safe to merge, but there is one behavioral inconsistency around the new custom_body parameter in the adapter-based passthrough path.
  • The URL-based passthrough fix addresses the reported crash and correctly allows Bedrock to supply a pre-parsed body. However, the adapter-based endpoint_func signature now accepts custom_body but does not use/forward it, which can lead to silent incorrect behavior for any callers relying on custom bodies when the adapter branch is selected.
  • litellm/proxy/pass_through_endpoints/pass_through_endpoints.py

Important Files Changed

Filename Overview
litellm/proxy/pass_through_endpoints/pass_through_endpoints.py Adds custom_body kwarg to create_pass_through_route endpoint closures and prefers the provided body over parsed request body in the URL-based passthrough path; adapter-based path currently ignores the new parameter.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Proxy as Proxy(FastAPI)
    participant Bedrock as bedrock_proxy_route
    participant Factory as create_pass_through_route
    participant Parse as _parse_request_data_by_content_type
    participant PT as pass_through_request
    participant Target as External Target URL

    Client->>Proxy: "POST /bedrock/{endpoint}"
    Proxy->>Bedrock: "bedrock_proxy_route(request)"
    Bedrock->>Bedrock: "parse JSON body"
    Bedrock->>Bedrock: "SigV4 sign headers/url"
    Bedrock->>Factory: "create_pass_through_route(target=prepped.url, headers=prepped.headers)"
    Factory-->>Bedrock: "endpoint_func"
    Bedrock->>Factory: "endpoint_func(custom_body=data)"

    alt "URL-based target"
        Factory->>Parse: "parse query/body from raw request"
        Factory->>Factory: "if custom_body != None use it"
        Factory->>PT: "pass_through_request(custom_body=final_custom_body)"
        PT->>Target: "HTTP request"
        Target-->>PT: "response"
        PT-->>Bedrock: "response"
    else "Adapter-based target"
        Factory->>Proxy: "chat_completion_pass_through_endpoint(...)"
        Note over Factory,Proxy: "custom_body currently not forwarded"
        Proxy-->>Bedrock: "response"
    end

    Bedrock-->>Client: "response"
Loading

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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 10, 2026

Additional Comments (1)

litellm/proxy/pass_through_endpoints/pass_through_endpoints.py
Unused custom_body param

In the adapter-based branch, endpoint_func now accepts custom_body but never forwards it, so callers that pass custom_body (like bedrock_proxy_route) will still have their custom body ignored whenever target resolves to an adapter (i.e., get_instance_fn(value=target) succeeds). If the intent is to support custom_body uniformly, it should be passed through to chat_completion_pass_through_endpoint (or removed from this signature if adapters can’t support it).

@jquinter
Copy link
Contributor

Review Feedback

Thanks for the fix — this addresses a real TypeError crash on Bedrock knowledge base retrieve requests via v1 passthrough.

Greptile's finding is correct: adapter-based path silently ignores custom_body

As @greptile-apps flagged, the adapter-based endpoint_func (line ~1097) now accepts custom_body but never forwards it to chat_completion_pass_through_endpoint:

async def endpoint_func(
    request: Request,
    fastapi_response: Response,
    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
    subpath: str = "",
    custom_body: Optional[dict] = None,  # ← accepted but never used
):
    return await chat_completion_pass_through_endpoint(
        fastapi_response=fastapi_response,
        request=request,
        adapter_id=adapter_id,
        user_api_key_dict=user_api_key_dict,
        # custom_body not forwarded
    )

This means the TypeError is fixed (no crash), but if a caller passes custom_body and the target resolves to an adapter, the body is silently dropped. In practice Bedrock targets resolve to URLs not adapters, so this is unlikely to trigger today — but it's a latent issue.

Suggestion: At minimum add a comment in the adapter path explaining why custom_body is intentionally not forwarded. Ideally, forward it if the downstream function supports it.

No tests

The PR doesn't include any tests. Even a basic test verifying endpoint_func can be called with custom_body=some_dict without TypeError would add confidence and prevent regressions.

URL-based path fix looks correct

The precedence logic (caller-supplied body > request-parsed body) is the right approach and the implementation is clean.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 10, 2026

You're right — chat_completion_pass_through_endpoint doesn't currently accept a custom_body parameter, so forwarding it would cause another TypeError.

Current state:

  • The adapter-based path accepts custom_body but silently ignores it
  • This prevents crashes but creates a latent bug
  • If Bedrock (or any caller) passes custom_body to an adapter target, the pre-parsed body is silently dropped and the request will re-parse from request.body()

Options:

  1. Document the limitation (minimal fix):
    Add a comment explaining custom_body is accepted for signature compatibility but ignored because chat_completion_pass_through_endpoint doesn't support it.

  2. Forward it (if supported downstream):
    If chat_completion_pass_through_endpoint can be extended to accept custom_body, forward it. This would require checking if the adapter flow can use pre-parsed bodies.

  3. Raise an error (strictest):
    If custom_body is not None in the adapter path, raise an error explaining that custom bodies aren't supported for adapter targets.

Since Bedrock targets currently resolve to URLs (not adapters), option 1 is the safest short-term fix. But if there's any chance adapter targets will need custom_body in the future, option 2 is more future-proof.

@krrishdholakia
Copy link
Member

@themavik can you please make the requested changes?

@shin-bot-litellm for monitoring

Address reviewer feedback on PR #20849:

- Document why the adapter-based endpoint_func accepts custom_body
  for signature compatibility but does not forward it (the underlying
  chat_completion_pass_through_endpoint does not support it).
- Add test_create_pass_through_route_custom_body_url_target: verifies
  that when a caller (e.g. bedrock_proxy_route) supplies custom_body,
  it takes precedence over the body parsed from the raw request.
- Add test_create_pass_through_route_no_custom_body_falls_back:
  verifies that the default path (no custom_body) correctly uses the
  request-parsed body, preserving existing behavior.

Both tests are fully mocked following the project's CONTRIBUTING.md
guidelines and the patterns established in the existing test file.

Co-authored-by: Cursor <cursoragent@cursor.com>
@themavik
Copy link
Contributor Author

Addressed the review feedback:

  1. Adapter-based path comment — Added an inline comment on the custom_body parameter in the adapter-based endpoint_func explaining it is accepted for signature compatibility with the URL-based path but not forwarded, since chat_completion_pass_through_endpoint does not support it.

  2. Tests — Added two mocked tests in tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py:

    • test_create_pass_through_route_custom_body_url_target: Verifies that when a caller (e.g. bedrock_proxy_route) supplies custom_body, it takes precedence over the body parsed from the raw request.
    • test_create_pass_through_route_no_custom_body_falls_back: Verifies that when custom_body is not provided, the existing behavior (use request-parsed body) is preserved.

    Both tests follow the project's mocked-test conventions from CONTRIBUTING.md and match the patterns already in the test file (e.g. test_create_pass_through_route_with_cost_per_request).

@jquinter
Copy link
Contributor

@greptile-apps review this PR please

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 12, 2026

Greptile Overview

Greptile Summary

Fixes a TypeError crash when Bedrock knowledge base retrieve requests are made through the v1 pass-through proxy. The bedrock_proxy_route passes custom_body=data to endpoint_func, but neither closure variant in create_pass_through_route accepted this keyword argument.

  • Added custom_body: Optional[dict] = None to both the adapter-based and URL-based endpoint_func signatures
  • In the URL-based path, when custom_body is provided by the caller, it is used directly instead of re-parsing the body from the raw request
  • The adapter-based path accepts but does not forward custom_body, since chat_completion_pass_through_endpoint does not support it
  • Two mock-only tests added to verify the fix and the fallback behavior

Confidence Score: 4/5

  • This PR is safe to merge — it's a targeted bug fix with minimal blast radius and good test coverage.
  • The fix is narrowly scoped to add a missing parameter and plumb it through correctly. The custom_body parameter defaults to None, so all existing callers (Vertex, Cohere, Anthropic, etc.) that don't pass it are unaffected. The two new tests are mock-based and verify both the fix and the fallback path. The only reason it's not a 5 is the adapter-based path silently ignores the parameter rather than forwarding it.
  • No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/pass_through_endpoints/pass_through_endpoints.py Added custom_body parameter to both adapter-based and URL-based endpoint_func closures, and updated body selection logic to prefer caller-supplied body over request-parsed body. Fixes TypeError crash on Bedrock knowledge base retrieve requests.
tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py Added two mock-only tests: one verifying custom_body is forwarded and takes precedence over the parsed request body, and one verifying fallback to parsed body when custom_body is not provided.

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

@krrishdholakia krrishdholakia merged commit ab4b619 into BerriAI:main Feb 14, 2026
6 of 8 checks passed
krrishdholakia pushed a commit that referenced this pull request Feb 14, 2026
…ctions (#21192)

* Access groups UI

* new badge changes

* adding tests

* fix: add custom_body parameter to endpoint_func in create_pass_through_route (#20849)

* fix: add custom_body parameter to endpoint_func in create_pass_through_route

The bedrock_proxy_route calls `endpoint_func(custom_body=data)` to
pass a pre-parsed, SigV4-signed request body. However, the
`endpoint_func` closure created by `create_pass_through_route` does
not accept a `custom_body` keyword argument, causing:

    TypeError: endpoint_func() got an unexpected keyword argument 'custom_body'

Add `custom_body: Optional[dict] = None` to both `endpoint_func`
definitions (adapter-based and URL-based). In the URL-based path,
when `custom_body` is provided by the caller, use it instead of
re-parsing the body from the raw request.

Fixes #16999

* Add tests for custom_body handling in create_pass_through_route

Address reviewer feedback on PR #20849:

- Document why the adapter-based endpoint_func accepts custom_body
  for signature compatibility but does not forward it (the underlying
  chat_completion_pass_through_endpoint does not support it).
- Add test_create_pass_through_route_custom_body_url_target: verifies
  that when a caller (e.g. bedrock_proxy_route) supplies custom_body,
  it takes precedence over the body parsed from the raw request.
- Add test_create_pass_through_route_no_custom_body_falls_back:
  verifies that the default path (no custom_body) correctly uses the
  request-parsed body, preserving existing behavior.

Both tests are fully mocked following the project's CONTRIBUTING.md
guidelines and the patterns established in the existing test file.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: themavik <themavik@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

* change to model name for backwards compat

* addressing comments

* allow editing of access group names

* fix: populate identity fields in proxy admin JWT early-return path (#21169)

* fix: populate identity fields in proxy admin JWT early-return path

When is_proxy_admin is True, the UserAPIKeyAuth early-return now includes
user_id, team_id, team_alias, team_metadata, org_id, and end_user_id
resolved from the JWT. Previously only user_role and parent_otel_span
were set, causing blank Team Name and Internal User in Request Logs UI.

* test: add unit tests for proxy admin JWT identity fields

* bump: version 0.4.36 → 0.4.37

* migration + build files

* Add pyroscope for observability (#21167)

* Pyroscope: require PYROSCOPE_APP_NAME and PYROSCOPE_SERVER_ADDRESS, add UTF-8 locale hint

- No defaults for PYROSCOPE_APP_NAME or PYROSCOPE_SERVER_ADDRESS; fail at startup if unset when Pyroscope is enabled
- Set LANG/LC_ALL to C.UTF-8 when unset to reduce malformed_profile (invalid UTF-8) rejections
- Startup message suggests PYTHONUTF8=1 if server rejects profiles
- Simplify LITELLM_ENABLE_PYROSCOPE in config_settings; document Pyroscope env vars as required with no default
- Add pyroscope_profiling to sidebar (Alerting & Monitoring)
- pyproject.toml: pyroscope-io as required dep on non-Windows (marker), in proxy extra

* proxy: add PYROSCOPE_SAMPLE_RATE env, use verbose logging, fix int type

- Add optional PYROSCOPE_SAMPLE_RATE env (integer, no default)
- Pass sample_rate to pyroscope.configure() as int for pyroscope-io
- Replace print with verbose_proxy_logger (info/warning)
- Document PYROSCOPE_SAMPLE_RATE in config_settings.md

* Address Greptile PR feedback: Pyroscope optional, docs, tests, docstring

- pyproject.toml: mark pyroscope-io as optional=true (proxy extra only)
- Add docs/my-website/docs/proxy/pyroscope_profiling.md (fix broken sidebar link)
- Add tests/test_litellm/proxy/test_pyroscope.py for _init_pyroscope()
- proxy_server: fix _init_pyroscope docstring (required server/app name, sample rate as int)

* Update litellm/proxy/proxy_server.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* fix(model_info): Add missing tpm/rpm for Gemini models (#21175)

Several Gemini models (TTS, native-audio, robotics, gemma) were missing
tpm/rpm values, causing test_get_model_info_gemini to fail.

Added conservative default values (tpm=250000, rpm=10) for preview models.
gemini-2.5-flash-preview-tts gets tpm=4000000, rpm=10.

Co-authored-by: OpenClaw <openclaw@users.noreply.github.com>

* fix(ci): Fix ruff lint error - unused import in vertex_ai_ingestion (#21178)

Co-authored-by: shin-bot-litellm <shin-bot-litellm@users.noreply.github.com>

* fix(ci): Fix mypy type errors across 6 files (#21179)

- vertex_ai/gemini: fix TypedDict assignment via explicit dict cast
- mcp_server: convert MutableMapping scope to dict for type safety
- pass_through_endpoints: simplify custom_body logic to fix type narrowing
- vector_store_endpoints: add Any annotation for dynamic hook return
- responses transformation: use dict() for Reasoning and setattr for dynamic field
- zscaler_ai_guard: add assert for api_base None check

Co-authored-by: shin-bot-litellm <shin-bot-litellm@users.noreply.github.com>

* fix(ci): Fix E2E login button selector - use exact match (#21176)

* fix(ci): Fix ruff lint error - unused import

Remove unused 'cast' import in vertex_ai_ingestion.py (ruff F401)

* fix(ci): Fix E2E login button selector - use exact match

Login button selector now matches both 'Login' and 'Login with SSO',
causing strict mode violation. Use { exact: true } to match only 'Login'.

---------

Co-authored-by: OpenClaw <openclaw@users.noreply.github.com>

* fix(mypy): Fix type errors across multiple files (#21180)

- vertex_ai/gemini/transformation.py: Fix TypedDict assignment via dict alias
- mcp_server/server.py: Convert ASGI scope to dict for type compatibility
- pass_through_endpoints.py: Add explicit Optional[dict] type annotation
- vector_store_endpoints/endpoints.py: Add Any type for dynamic proxy hook
- responses transformation.py: Use dict(Reasoning()) and setattr for compatibility
- zscaler_ai_guard.py: Add assert for api_base nullability

Co-authored-by: OpenClaw <openclaw@users.noreply.github.com>

* [Guardrails] Add guardrail pipeline support for conditional sequential execution (#21177)

* Add pipeline type definitions for guardrail pipelines

PipelineStep, GuardrailPipeline, PipelineStepResult, PipelineExecutionResult
with validation for actions (allow/block/next/modify_response) and modes.

* Export pipeline types from policy_engine types package

* Add optional pipeline field to Policy model

* Add pipeline executor for sequential guardrail execution

* Parse pipeline config in policy registry

* Add pipeline validation in policy validator

* Add pipeline resolution and managed guardrail tracking

* Resolve pipelines and exclude managed guardrails in pre-call

* Integrate pipeline execution into proxy pre_call_hook

* Add test guardrails for pipeline E2E testing

* Add example pipeline config YAML

* Add unit tests for pipeline type definitions

* Add unit tests for pipeline executor

* Update litellm/proxy/policy_engine/pipeline_executor.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Update litellm/proxy/utils.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Add pipeline flow builder UI for guardrail policies (#21188)

* Add pipeline type definitions for guardrail pipelines

PipelineStep, GuardrailPipeline, PipelineStepResult, PipelineExecutionResult
with validation for actions (allow/block/next/modify_response) and modes.

* Export pipeline types from policy_engine types package

* Add optional pipeline field to Policy model

* Add pipeline executor for sequential guardrail execution

* Parse pipeline config in policy registry

* Add pipeline validation in policy validator

* Add pipeline resolution and managed guardrail tracking

* Resolve pipelines and exclude managed guardrails in pre-call

* Integrate pipeline execution into proxy pre_call_hook

* Add test guardrails for pipeline E2E testing

* Add example pipeline config YAML

* Add unit tests for pipeline type definitions

* Add unit tests for pipeline executor

* Add pipeline column to LiteLLM_PolicyTable schema

* Add pipeline field to policy CRUD request/response types

* Add pipeline support to policy DB CRUD operations

* Add PipelineStep and GuardrailPipeline TypeScript types

* Add Zapier-style pipeline flow builder UI component

* Integrate pipeline flow builder with mode toggle in policy form

* Add pipeline display section to policy info view

* Add unit tests for pipeline in policy CRUD types

* Refactor policy form to show mode picker first with icon cards

* Add full-screen FlowBuilderPage component for pipeline editing

* Wire up full-screen flow builder in PoliciesPanel with edit routing

* Restyle flow builder to match dev-tool UI aesthetic

* Restyle flow builder cards to match reference design

* Update step card to expanded layout with stacked ON PASS / ON FAIL sections

* Add end card to flow builder showing return to normal control flow

* Add PipelineTestRequest type for test-pipeline endpoint

* Export PipelineTestRequest from policy_engine types

* Add POST /policies/test-pipeline endpoint

* Add testPipelineCall networking function

* Add PipelineStepResult and PipelineTestResult types

* Add test pipeline panel to flow builder with run button and results display

* Fix pipeline executor: inject guardrail name into metadata so should_run_guardrail allows execution

* Update litellm/proxy/policy_engine/pipeline_executor.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Update litellm/proxy/utils.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Update litellm/proxy/policy_engine/policy_endpoints.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Update litellm/proxy/policy_engine/pipeline_executor.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* fix(responses-bridge): extract list-format system content into instructions

When system message content is a list of content blocks
(e.g. [{"type": "text", "text": "..."}]) instead of a plain string,
the responses API bridge was passing it through as a role: system
message in the input items. APIs like ChatGPT Codex reject this
with "System messages are not allowed".

This happens when requests come through the Anthropic /v1/messages
adapter, which converts system prompts into list-format content blocks
in the OpenAI chat completions format.

Fix: extract text from list content blocks and concatenate into the
instructions parameter, matching the existing behavior for string
system content.

* test: add tests for system message extraction in responses bridge

Add three tests for convert_chat_completion_messages_to_responses_api:
- String system content → instructions
- List-format content blocks → instructions (the bug this PR fixes)
- Multiple system messages (mixed string and list) concatenated

* fix: add warning log for unexpected system content types

Address review feedback: add an else clause that logs a warning
for any system content that is neither str nor list, rather than
silently dropping it.

---------

Co-authored-by: yuneng-jiang <yuneng.jiang@gmail.com>
Co-authored-by: The Mavik <179817126+themavik@users.noreply.github.com>
Co-authored-by: themavik <themavik@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
Co-authored-by: Alexsander Hamir <alexsanderhamirgomesbaptista@gmail.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: shin-bot-litellm <shin-bot-litellm@berri.ai>
Co-authored-by: OpenClaw <openclaw@users.noreply.github.com>
Co-authored-by: shin-bot-litellm <shin-bot-litellm@users.noreply.github.com>
sameetn pushed a commit to sameetn/litellm that referenced this pull request Feb 16, 2026
…h_route (BerriAI#20849)

* fix: add custom_body parameter to endpoint_func in create_pass_through_route

The bedrock_proxy_route calls `endpoint_func(custom_body=data)` to
pass a pre-parsed, SigV4-signed request body. However, the
`endpoint_func` closure created by `create_pass_through_route` does
not accept a `custom_body` keyword argument, causing:

    TypeError: endpoint_func() got an unexpected keyword argument 'custom_body'

Add `custom_body: Optional[dict] = None` to both `endpoint_func`
definitions (adapter-based and URL-based). In the URL-based path,
when `custom_body` is provided by the caller, use it instead of
re-parsing the body from the raw request.

Fixes BerriAI#16999

* Add tests for custom_body handling in create_pass_through_route

Address reviewer feedback on PR BerriAI#20849:

- Document why the adapter-based endpoint_func accepts custom_body
  for signature compatibility but does not forward it (the underlying
  chat_completion_pass_through_endpoint does not support it).
- Add test_create_pass_through_route_custom_body_url_target: verifies
  that when a caller (e.g. bedrock_proxy_route) supplies custom_body,
  it takes precedence over the body parsed from the raw request.
- Add test_create_pass_through_route_no_custom_body_falls_back:
  verifies that the default path (no custom_body) correctly uses the
  request-parsed body, preserving existing behavior.

Both tests are fully mocked following the project's CONTRIBUTING.md
guidelines and the patterns established in the existing test file.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: themavik <themavik@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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]: TypeError in bedrock_proxy_route: endpoint_func() got unexpected keyword argument 'custom_body'

3 participants