mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-17 08:18:09 +00:00
Two fail-safes for the /v1/messages → Bedrock Invoke pass-through so new Anthropic-only extensions Claude Code starts sending can't reach Bedrock and trigger a 400 "Extra inputs are not permitted": 1. Top-level body fields are filtered to a typed allowlist. New `BedrockInvokeAnthropicMessagesRequest` TypedDict (in `litellm/types/llms/bedrock.py`) captures the Bedrock Invoke Anthropic Messages body schema; the runtime allowlist is derived from its `__annotations__` so the type and the filter can't drift. Anchored to the AWS reference page in docstrings + transform comment. An exact-set test pins the resolved allowlist so any future edit forces conscious review. Drops context_management, output_config, speed, mcp_servers, container, inference_geo, internal litellm_metadata, and any future Anthropic addition. output_format stays as an active inline-schema conversion (not just a strip). 2. The anthropic-beta header list is filtered + transformed against the bedrock mapping for ALL betas, not just auto-injected ones. The previous code union'd user-provided betas back in unfiltered, so a client on a new Anthropic-direct beta (e.g. advisor-tool-…, context-management-…) could still pin the request to fail. In a proxy context the client can't know the backend is Bedrock; the provider mapping is authoritative. User-provided drops are logged at WARNING so intentional overrides leave a breadcrumb. Updates one existing test that happened to assert on the old buggy pass-through (it used output-128k-2025-02-19, which is null in the bedrock mapping and would 400 at runtime); rewrote it against a bedrock-supported beta. Scope: messages/invoke only. The same user-beta bypass exists in chat/invoke but that's a different code path with different user-expectation trade-offs — follow-up.
In total litellm runs 1000+ tests
[02/20/2025] Update:
To make it easier to contribute and map what behavior is tested,
we've started mapping the litellm directory in tests/test_litellm
This folder can only run mock tests.