Skip to content

test: an event JSON cannot serialize is dropped alone - #1138

Merged
eli-r-ph merged 2 commits into
v1from
eli/v1-circular-reference-test
Oct 28, 2026
Merged

eli-r-ph merged 2 commits into
v1from
eli/v1-circular-reference-test

Conversation

@eli-r-ph

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

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

The 8.0 migration guide says an event that can't be serialized to JSON, such as one with a circular reference, is dropped and logged. Since #1120 removed the non-finite case, no test checks that such an event costs only itself and not its batch.

  • Add two cases to test_malformed_before_send_event_does_not_stop_consumer_or_shutdown: the bad event is dropped, the valid event in the same batch is sent, and the consumer and shutdown still finish.
    • A circular value fails cleaning, so its event is dropped before it is queued.
    • A complex value passes cleaning and fails in the consumer, so it covers the per-event serialization guard.

💚 How did you test it?

pytest posthog/test/test_before_send.py -k malformed: 3 passed. Without the consumer's per-event serialization guard, the complex case fails because the bad event is sent with the batch.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code (Claude Opus 5.5) added this test in response to a review comment on #1120.

🤖 Generated with Claude Code

@eli-r-ph eli-r-ph self-assigned this Oct 28, 2026
@eli-r-ph
eli-r-ph marked this pull request as ready for review October 28, 2026 16:47
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 28, 2026 16:47

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

The circular-input case verifies that malformed hook output is dropped without blocking valid capture or shutdown. One optional coverage improvement is noted inline: this fixture is rejected during cleaning, rather than by the consumer serialization guard.

AI-assisted review.

Comment thread posthog/test/test_before_send.py
@eli-r-ph
eli-r-ph merged commit 2a2f26d into v1 Oct 28, 2026
40 of 41 checks passed
@eli-r-ph
eli-r-ph deleted the eli/v1-circular-reference-test branch October 28, 2026 20:17
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