Skip to content

Commit

Permalink
fix(batch-exports): Set default function when JSON dumping
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfarias committed Oct 30, 2024
1 parent 1fbc799 commit 5a74a08
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions posthog/temporal/batch_exports/temporary_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def write_dict(self, d: dict[str, typing.Any]) -> int:
# We tried, fallback to the slower but more permissive stdlib
# json.
logger.exception("PostHog $web_vitals event didn't match expected structure")
dumped = json.dumps(d).encode("utf-8")
dumped = json.dumps(d, default=str).encode("utf-8")
n = self.batch_export_file.write(dumped + b"\n")
else:
dumped = orjson.dumps(d, default=str)
Expand All @@ -492,7 +492,7 @@ def write_dict(self, d: dict[str, typing.Any]) -> int:
# In this case, we fallback to the slower but more permissive stdlib
# json.
logger.exception("Orjson detected a deeply nested dict: %s", d)
dumped = json.dumps(d).encode("utf-8")
dumped = json.dumps(d, default=str).encode("utf-8")
n = self.batch_export_file.write(dumped + b"\n")
else:
# Orjson is very strict about invalid unicode. This slow path protects us
Expand Down

0 comments on commit 5a74a08

Please sign in to comment.