Skip to content

Commit

Permalink
fix(serializer): fallback on utf-8 decoder error
Browse files Browse the repository at this point in the history
  • Loading branch information
hassiebp committed Dec 9, 2024
1 parent 39e226f commit 6d3c5b1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion langfuse/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def default(self, obj: Any):
return str(obj)

if isinstance(obj, bytes):
return obj.decode("utf-8")
try:
return obj.decode("utf-8")
except UnicodeDecodeError:
return "<not serializable bytes>"

if isinstance(obj, (date)):
return obj.isoformat()
Expand Down

0 comments on commit 6d3c5b1

Please sign in to comment.