Skip to content

Commit 3ea00c2

Browse files
committed
fix: coerce non-string metadata values instead of dropping them
The v4 migration guide states non-string metadata values are "automatically coerced to strings," but the implementation drops them with a warning. This breaks LangGraph integration since LangGraph injects non-string metadata (langgraph_step=int, langgraph_triggers=list, langgraph_path=tuple) into RunnableConfig at runtime. Coerce non-string values via str() before validation, matching the documented behavior. Fixes #1571
1 parent 9006683 commit 3ea00c2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

langfuse/_client/propagation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ def _propagate_attributes(
253253
validated_metadata: Dict[str, str] = {}
254254

255255
for key, value in metadata.items():
256+
# Coerce non-string values to strings (e.g., LangGraph injects
257+
# langgraph_step=int, langgraph_triggers=list, langgraph_path=tuple)
258+
if not isinstance(value, str):
259+
value = str(value)
256260
if _validate_string_value(value=value, key=f"metadata.{key}"):
257261
validated_metadata[key] = value
258262

0 commit comments

Comments
 (0)