8 views
-/https://github.com/berriai/litellm/issues/26977
GitHub Β· issue

#26977 [Bug]: langfuse_otel set_messages crashes on litellm.Message objects (Object of type Message is not JSON serializable)

  • State: open
  • Author: @taxfree-python
  • Labels: llm translation, stale, SDK

### Check for existing issues

I searched and found #13672 (the meta-bug for langfuse_otel pulling in Arize/Phoenix attribute setters). This issue is one specific instance of that family β€” `set_messages` choking on pydantic `Message` objects β€” that hasn't been filed or fixed.

### What happened?

When `langfuse_otel` is registered as a callback and the caller passes `messages=list[litellm.Message]` (a documented public API exposed via the top-level `litellm.Message` export), every LLM call logs:

``` LiteLLM:ERROR: _utils.py:415 - [Arize/Phoenix] Failed to set OpenInference span attributes: Object of type Message is not JSON serializable ```

The trace is still exported, but the input payload is dropped from the span and the span kind is degraded from `GENERATION` to a generic span (the `OPENINFERENCE_SPAN_KIND` attribute is set later in the same try/except block, so it gets skipped along with `set_messages` when the latter raises).

Root cause: `LangfuseLLMObsOTELAttributes.set_messages` does `json.dumps({"messages": kwargs.get("messages"), ...})` directly. `litellm.Message` is a pydantic v2 model and is not JSON-serializable by default β€” `json.dumps` raises `TypeError`, and `ariz…

GitHub resolver

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

Refresh page
vote history (1 events)
#0 of 0 Β· 31d17h58m31s ago β€” entered Β· #import:https:::github.com:berriai:litellm post #2984
Issue #30320 is harder because it spans dependency metadata, environment-specific installation behavior, provider initialization, and actionable startup validation, requiring broader packaging and proxy integration tests. Issue #26977 is comparatively localized to serialization and callback attribute handling with targeted regression coverage.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search