fix(anthropic_messages): strip non-user_id keys from metadata before forwarding - #27262
Closed
mateo-berri wants to merge 2 commits into
Closed
fix(anthropic_messages): strip non-user_id keys from metadata before forwarding#27262mateo-berri wants to merge 2 commits into
mateo-berri wants to merge 2 commits into
Conversation
The 'Model Access Group' picker in the Add Model flow only listed legacy access groups discovered from existing deployments' `model_info.access_groups` (via /models?only_model_access_groups=true). Unified access groups created through the Access Groups page (stored in LiteLLM_AccessGroupTable, served by /v1/access_group) were never merged in, so a freshly-created group like 'Engineering' did not appear and admins had to free-type it from memory. Pull both sources: - AddModelForm: combine the legacy /models response with useAccessGroups() - add_auto_router_tab and edit_auto_router_modal: same merge for parity - ModelsAndEndpointsView.availableModelAccessGroups (powers ModelInfoView's edit dropdown) now also folds in unified group names Names are deduped via a Set and sorted for stable rendering. The hook is gated on admin role inside useAccessGroups itself, so non-admins see the same list they did before. Adds an AddModelForm test that opens the dropdown and asserts both the legacy entries and a mocked unified group are listed. Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
…forwarding The Anthropic Messages API only accepts `user_id` inside `metadata`, and Vertex AI / Azure AI Anthropic mirror that contract — they 400 with `metadata.tags: Extra inputs are not permitted` on any other key. PR #24661 added this filter to the chat/completions path (`AnthropicConfig.transform_request`), but the unified `/v1/messages` endpoint (used by Claude Code via `ANTHROPIC_BASE_URL`) goes through `AnthropicMessagesConfig.transform_anthropic_messages_request`, which had no equivalent guard. Routing/budget tags injected by key/team/project metadata or deployment-level routing therefore leaked into the outgoing `metadata` dict and broke requests against Vertex AI Anthropic. Apply the same final-strip filter in the unified messages transform so the safeguard covers both code paths.
|
|
1 task
7 tasks
Contributor
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewType
🐛 Bug Fix
Changes
The Anthropic Messages API only accepts
user_idinsidemetadata, and Vertex AI / Azure AI Anthropic mirror that contract — they 400 withmetadata.tags: Extra inputs are not permittedon any other key.PR #24661 added this filter to the chat/completions path (
AnthropicConfig.transform_request), but the unified/v1/messagesendpoint (used by Claude Code viaANTHROPIC_BASE_URL) goes throughAnthropicMessagesConfig.transform_anthropic_messages_request, which had no equivalent guard. Routing/budget tags injected by key/team/project metadata or deployment-level routing therefore leaked into the outgoingmetadatadict and broke requests against Vertex AI Anthropic.This PR applies the same final-strip filter in the unified messages transform so the safeguard covers both code paths, and adds a unit test in
tests/test_litellm/covering the filter behavior.Files touched
litellm/llms/anthropic/experimental_pass_through/messages/transformation.py— strip non-user_idkeys frommetadatabefore forwarding.tests/test_litellm/.../test_anthropic_messages_metadata_filter.py— new unit test for the filter.Slack Thread