Skip to content

fix!: drop only the invalid event, not its whole batch - #1052

Merged
eli-r-ph merged 5 commits into
v1from
v1-wire-hygiene
Oct 22, 2026
Merged

eli-r-ph merged 5 commits into
v1from
v1-wire-hygiene

Conversation

@eli-r-ph

@eli-r-ph eli-r-ph commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Based on v1 (#1051 is merged). Capture v1 rejects the whole request for some invalid events, such as one containing NaN or a non-string name, so one bad event loses every event sent with it. This PR drops only the bad event, raises the analytics size limit to capture's own, and keeps event content out of logs.

Changes

  • An event with a missing, empty or non-string name is dropped, with one warning per reason.
  • An event that contains NaN or Infinity is dropped alone instead of breaking the request.
  • A property or option key that JSON cannot represent, such as a tuple, is dropped from its event.
  • The analytics per-event limit is now 10 MiB, capture's request limit, instead of 900 KiB.
  • A personal API key (phx_...) disables the client with one error log, like an empty key.
  • Logs no longer include event content or invalid timestamp values.
  • Migration guide and changeset updated.
  • The module-level client stays disabled for a personal API key; setup() no longer re-enables it on each module call.

💚 How did you test it?

  • Tests cover each drop, including a name set by before_send, and check that the rest of the batch is still sent.
  • The NaN and event-name tests fail with the change reverted.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Claude Code under the direction of the assignee.

🤖 Generated with Claude Code

@eli-r-ph eli-r-ph self-assigned this Oct 13, 2026
@eli-r-ph
eli-r-ph marked this pull request as ready for review October 13, 2026 05:27
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 13, 2026 05:27
@eli-r-ph eli-r-ph changed the title fix: drop only the invalid event, and size analytics by capture's limits fix!: drop only the invalid event, not its whole batch Oct 13, 2026
@eli-r-ph
eli-r-ph force-pushed the v1-wire-hygiene branch 2 times, most recently from ff2fed1 to d205df8 Compare October 14, 2026 03:48

@dustinbyrne dustinbyrne 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.

AI-assisted review.

The invalid-event isolation changes are well scoped, and existing CI is green. One correction remains: module setup overrides the new personal-key disabled state. There are also two optional migration-guide wording corrections. Findings apply only to #1052’s diff against #1051; inspected downstream heads do not resolve them.

Validation: source inspection; the regression sketch is unexecuted.

Comment thread posthog/client.py
Comment thread docs/migration-7.x-to-8.0.md Outdated
Comment thread docs/migration-7.x-to-8.0.md Outdated
Base automatically changed from v1-sync-main-7.68 to v1 October 20, 2026 17:07
eli-r-ph and others added 3 commits October 20, 2026 10:08
An event with a missing, empty or non-string name, or one that cannot be
serialized (for example with NaN), is dropped alone instead of failing the
whole batch at capture. A property key JSON cannot represent is dropped from
its event. The analytics per-event limit is capture's 10 MiB request limit,
since capture reports an event over its per-event limit in the response.
A personal API key disables the client like an empty key, and logs no longer
include event content or invalid timestamp values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wo guide claims

- setup() re-derived disabled from the key being non-empty, which
  re-enabled a client given a phx_ key on every module call.
- The guide now says finite float keys are stringified (NaN keys drop
  the event) and that only the SDK's own log lines drop event content.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
eli-r-ph and others added 2 commits October 20, 2026 16:21
before_send can set any value, and capture v1 rejects the whole request
for a non-string distinct_id. The SDK now drops that event locally with
one warning per reason, and never converts the value or makes up an ID.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@eli-r-ph
eli-r-ph merged commit fc04fbc into v1 Oct 22, 2026
75 checks passed
@eli-r-ph
eli-r-ph deleted the v1-wire-hygiene branch October 22, 2026 17:27
@eli-r-ph eli-r-ph mentioned this pull request Oct 23, 2026
3 of 4 tasks
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.

3 participants