What breaks
EventSerializer._default_inner() in langfuse/_utils/serializer.py silently converts float('-inf') to the string "Infinity" instead of "-Infinity". Any LLM output, metric, or metadata field containing negative infinity is sent to the Langfuse server with the wrong sign, causing silent data corruption.
How to trigger
import json
from langfuse._utils.serializer import EventSerializer
s = EventSerializer()
print(s.encode(float('inf'))) # "Infinity" ✓
print(s.encode(float('-inf'))) # "Infinity" ✗ — should be "-Infinity"
Root cause
The guard if isinstance(obj, float) and math.isinf(obj): return "Infinity" does not check the sign of the infinite value. math.isinf() returns True for both float('inf') and float('-inf'), so both are mapped to the same positive string.
What breaks
EventSerializer._default_inner()inlangfuse/_utils/serializer.pysilently convertsfloat('-inf')to the string"Infinity"instead of"-Infinity". Any LLM output, metric, or metadata field containing negative infinity is sent to the Langfuse server with the wrong sign, causing silent data corruption.How to trigger
Root cause
The guard
if isinstance(obj, float) and math.isinf(obj): return "Infinity"does not check the sign of the infinite value.math.isinf()returnsTruefor bothfloat('inf')andfloat('-inf'), so both are mapped to the same positive string.