Skip to content

fix: serialize non-finite event properties as null - #150

Merged
marandaneto merged 1 commit into
mainfrom
fix/non-finite-event-properties-20261022
Oct 22, 2026
Merged

marandaneto merged 1 commit into
mainfrom
fix/non-finite-event-properties-20261022

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

Numeric NaN and infinities currently produce invalid JSON in queued analytics events. Reloading those events can truncate following properties or stall on arrays, preventing a healthy neighboring event from flushing.

Serialize non-finite float and double values as JSON null, preserving object members and array positions. Finite values, literal strings, caller input, and existing null behavior remain unchanged. The fix stays in the numeric writer, without changing parser or queue policy.

Related Python work: PostHog/posthog-python#1081. The shared capture, HTTP-client, and event-batcher specs do not explicitly define non-finite handling.

💚 How did you test it?

Regression tests failed before the fix and pass afterward for float/double NaN and both infinities, nested dictionaries, arrays, and objects inside arrays. They check strict persisted JSON, actual queue reload, and a batch containing a healthy event.

Focused neighboring tests: 146 passed. Full managed-code suite: 540 passed, 3 existing skips. Formatting, netstandard2.1 Unity-stub build, and public API checks passed. Final signed-commit branch autoreview passed without actionable findings. Real Unity/platform execution was not performed.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed. (No public API documentation change needed.)
  • No breaking change or entry added to the changelog. (Patch changeset included.)

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

A patch changeset was written directly in the documented format.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Human DRI: @marandaneto.

A coding agent used local bash/.NET tooling and the pr, karpathy-guidelines, test-audit, and autoreview skills for a maintainer-directed fix. The serializer substitutes null only for numeric non-finite values. Parser hardening, historical malformed-record repair, and unrelated null behavior are outside this change. Human review is required.

@marandaneto marandaneto self-assigned this Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

posthog-unity Compliance Report

Date: 2026-10-22 11:57:10 UTC
Duration: 105971ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

✅ 29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 92ms
Format Validation.Event Has Uuid ✅ 12ms
Format Validation.Event Has Lib Properties ✅ 9ms
Format Validation.Distinct Id Is String ✅ 9ms
Format Validation.Token Is Present ✅ 9ms
Format Validation.Custom Properties Preserved ✅ 16ms
Format Validation.Event Has Timestamp ✅ 9ms
Retry Behavior.Retries On 503 ✅ 6522ms
Retry Behavior.Does Not Retry On 400 ✅ 2015ms
Retry Behavior.Does Not Retry On 401 ✅ 2013ms
Retry Behavior.Respects Retry After Header ✅ 8019ms
Retry Behavior.Implements Backoff ✅ 18533ms
Retry Behavior.Retries On 500 ✅ 5519ms
Retry Behavior.Retries On 502 ✅ 5518ms
Retry Behavior.Retries On 504 ✅ 5521ms
Retry Behavior.Max Retries Respected ✅ 18534ms
Deduplication.Generates Unique Uuids ✅ 15ms
Deduplication.Preserves Uuid On Retry ✅ 5515ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 11519ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5519ms
Deduplication.No Duplicate Events In Batch ✅ 15ms
Deduplication.Different Events Have Different Uuids ✅ 9ms
Compression.Sends Gzip When Enabled ✅ 9ms
Batch Format.Uses Proper Batch Structure ✅ 7ms
Batch Format.Flush With No Events Sends Nothing ✅ 4ms
Batch Format.Multiple Events Batched Together ✅ 12ms
Error Handling.Does Not Retry On 403 ✅ 2010ms
Error Handling.Does Not Retry On 413 ✅ 2012ms
Error Handling.Retries On 408 ✅ 5516ms

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 21ms
Request Payload.Flags Request Uses V2 Query Param ✅ 10ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 7ms
Request Payload.Flags Request Omits Authorization Header ✅ 6ms
Request Payload.Token In Flags Body Matches Init ✅ 5ms
Request Payload.Groups Round Trip ✅ 6ms
Request Payload.Groups Default To Empty Object ✅ 7ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 6ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 5ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 6ms
Request Lifecycle.No Flags Request On Init Alone ✅ 3ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 7ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 8ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 7ms
Retry Behavior.Retries Flags On 502 ✅ 509ms
Retry Behavior.Retries Flags On 504 ✅ 510ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 9ms

@marandaneto
marandaneto marked this pull request as ready for review October 22, 2026 13:28
@marandaneto
marandaneto requested a review from a team as a code owner October 22, 2026 13:28

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostHog Review · Standard · reviewed a6a591a: no findings.

This Standard review started from the posthog-review label. Comment @posthog review --deep for a Deep review, or @posthog help to see all commands.

@posthog posthog Bot removed the reviewhog label Oct 22, 2026
@marandaneto
marandaneto merged commit c800274 into main Oct 22, 2026
17 checks passed
@marandaneto
marandaneto deleted the fix/non-finite-event-properties-20261022 branch October 22, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants