Repository navigation
docs(capture): normalize non-finite numeric event properties to JSON null - #140
Draft
posthog[bot] wants to merge 3 commits into
Draft
posthog[bot] wants to merge 3 commits into
posthog[bot] wants to merge 3 commits into
Conversation
…null Six SDKs independently fixed the same data-loss bug in one week: a NaN or infinity in an event property produced a payload ingestion rejected, or one the SDK could not serialize at all, losing the event and often its batch. Four of those PRs noted that the shared specs prescribe no policy here. Adds a capture requirement fixing the no-data-loss and array-slot rules, and records the one point where the SDKs still diverge (object-member placement) instead of picking a winner. Generated-By: PostHog Desktop Task-Id: b122d073-a451-4d4c-8f41-394e62cb901c
This was referenced Oct 25, 2026
Contributor
|
Noted, updated: posthog-go v2 now sends non-finite numbers as null too (PostHog/posthog-go#394), and the capture v1 spec in #146 now requires null for every SDK, matching this PR. |
turnipdabeets
changed the base branch from
docs/acceptance-step-catalogue
to
main
October 27, 2026 22:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Six SDKs independently fixed the same bug in the same week: an event property holding a non-finite floating-point number (NaN, +Infinity, -Infinity) produced a payload that ingestion rejected, or that the SDK itself refused to serialize — so the event, and in several SDKs the whole batch around it, was lost.
Four of those PRs say in their own description that the shared capture, HTTP-client and event-batcher specs do not prescribe a policy here, so each SDK had to pick one. They converged, which is the point — but nothing in this repo holds the line for the next SDK or the next port.
Source changes:
NaN/Infinity; strict parsers in the ingestion path rejected the batch"NaN"/"Infinity"/"-Infinity"posthog-js never had the bug:
JSON.stringifyalready turns a non-finite number intonull.What changed
One requirement added to
openspec/specs/capture/spec.md, with the change archived underopenspec/changes/archive/2026-10-23-specify-non-finite-number-serialization/:Capture normalizes non-finite numeric property values. A non-finite number is replaced with JSON
null; the bareNaN/Infinitytokens and the string forms are both forbidden. A non-finite value never costs data — not the call, not the event, not the batch, not a healthy neighbor. Normalization is recursive, keeps array indices, does not mutate the caller's container, and applies to queued and immediate capture, afterbefore_send, and on every disk serialization (a persistedNaNis unparseable on restore). Byte budgets measure the normalized form, so buffered and emitted forms agree. Literal strings like"NaN"and finite values of any magnitude are untouched, and unsupported types keep their existing error behavior.Uncertain / left out
nullas an object member; posthog-flutter omits the member instead, so the result matches the existing Capture drops null-valued object properties requirement — which says a null-valued member must not be serialized as JSONnull. Both readings are defensible and the answer is a judgment call about that interaction, so this PR records the divergence rather than picking a winner. Worth a human decision. Array slots have no such latitude and are specified.Validation
openspec validate specify-non-finite-number-serialization --type change --strictpasses with only the repo's usual long-requirement warning. The repo-wideopenspec validate --specs --strictrun is unchanged at 32 passed / 32 failed —capturewas already in the failing bucket for pre-existing long-requirement warnings, and no spec newly fails. These are specification checks, not executed SDK conformance tests.Created with PostHog Desktop
🤖 Generated with Claude Code