7 views
-/https://github.com/berriai/litellm/issues/30662
GitHub · issue

#30662 [Bug]: Anthropic /v1/messages passthrough serializes callback-injected non-serializable metadata into the request body

  • State: open
  • Author: @jgreer013
  • Labels: llm translation

### Check for existing issues

☑ Searched — not a duplicate. Closest is #12354 (`_Span is not JSON serializable`, but spend-logs / `litellm_parent_otel_span`, not the Anthropic passthrough request body).

### What happened?

When a litellm `input_callback` adds a non-JSON-serializable value to metadata, the Anthropic `/v1/messages` passthrough serializes that polluted metadata into the **outbound request body** via a bare `json.dumps(request_body)`, crashing the call. Real-world trigger: Sentry's `LiteLLMIntegration` stores a live `Span` at `metadata["_sentry_span"]` (root cause filed at getsentry/sentry-python#6596).

Note: caller-supplied metadata is already correctly sanitized — `validate_anthropic_api_metadata` strips unknown keys (verified: passing `metadata={"user_id":"x","evil":<obj>}` yields body `{"user_id":"x"}`). The gap is specifically values injected into `litellm_params["metadata"]` by input-callbacks **after** validation, which still reach the serialized request body.

**Expected:** the passthrough body builder should not let non-serializable callback-injected metadata into the provider request — strip it (as #15728 did for `litellm_parent_otel_span`) or serialize wi…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (3 events)
#0 of 0 · 31d19h6m35s ago — entered · #import:https:::github.com:berriai:litellm post #1767
The Cloudflare work spans new multimodal provider integrations, binary and streaming handling, standardized transformations, capability metadata, tests, and documentation. The other issue is a narrowly scoped serialization-safety fix in an existing request-building path, with a smaller regression surface.
Issue 22998 is harder because it involves diagnosing migration-state inconsistencies, safely repairing schema deployment behavior, handling upgrade and recovery paths, and validating compatibility across database environments. Issue 30662 is comparatively localized to request-body sanitization and focused regression tests.
#0 of 0 · 31d18h53m9s ago — current · #import:https:::github.com:berriai:litellm post #1983
Issue #30662 is harder because it requires tracing callback metadata through the passthrough pipeline, defining safe sanitization or serialization behavior, and adding regression coverage across integrations; #28081 is a narrower provider-specific request translation fix.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search