Skip to content

fix(capture): send the event uuid in canonical form - #119

Merged
turnipdabeets merged 2 commits into
mainfrom
posthog/capture-canonical-event-uuid
Oct 21, 2026
Merged

turnipdabeets merged 2 commits into
mainfrom
posthog/capture-canonical-event-uuid

Conversation

@posthog

@posthog posthog Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Why

Capture v1 answers a 2xx with a per-event results map keyed by the canonical lowercase hyphenated uuid, while the request side parses an event uuid leniently (uppercase, unhyphenated, braced, urn:uuid:). An SDK that forwards a caller-supplied uuid unchanged cannot find its own events in the response: a retry verdict is never retried, a drop verdict never reaches the error callback, and the event is silently treated as accepted. The capture spec said only that uuid is a "caller override or a freshly generated UUIDv7", so nothing stopped the next SDK from reintroducing the bug.

Source changes

What changed in the spec

  • New capture requirement Event uuid is sent in canonical form: canonical on the wire, a caller override in another accepted form normalized before enqueue, the returned uuid equal to the value sent, normalization re-applied after the before-send hook, and an unparseable override logged and replaced with a generated UUIDv7 rather than failing the call. Two @server scenarios cover normalization and the fallback.
  • Narrative: Behavior steps 5, 6 and 8 and the Error handling list now say the same thing in passing.

Proposed, applied and archived on this branch per AGENTS.md. openspec validate --specs --strict totals are unchanged from main (the remaining warnings are the pre-existing long-requirement ones across the repo).

Uncertain / worth a look

  • Both implementations are on unreleased v1 branches. This is a bug fix against behavior the backend already has, so it is recorded now, but it is worth re-checking if the capture v1 series changes shape before release.
  • Scenarios are tagged @server (applicability only, not the opt-in @sdk:server) because both shipped fixes are server SDKs. Client SDKs that accept a uuid override are presumably the same, but this PR does not assert it.
  • Not included, and flagged for human review: the rest of posthog-python's capture v1 series (#1017–#1020) introduces a per-event verdict/error model (CaptureError, CaptureEventResult, aggregate loss logging, 100ms×2^attempt backoff capped at 30s, Consumer retries default 3) aligned with posthog-go's v1. That is a larger new contract area with no spec home today, so it needs a deliberate call rather than an inferred spec edit.

Created with PostHog Desktop

🤖 Generated with Claude Code

Capture v1 keys its per-event results map by the canonical lowercase
hyphenated uuid while parsing request uuids leniently, so an event sent
under a non-canonical caller-supplied uuid cannot be correlated with its
own verdict. posthog-go and posthog-python both now normalize the uuid
before send, after before_send, and fall back to a generated UUIDv7 for
an unparseable override. Record that in the capture spec.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 1b508480-1639-4fda-8a0f-13880afee91c
…ng to shipped code

posthog-js passes a valid caller uuid through unchanged, so the rule is
scoped to server SDKs (matching the @server scenarios). posthog-go v1 does
not log the fallback and posthog-python v1 deliberately omits the value from
its warning, so the warning is a SHOULD and SHOULD NOT include the value.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@turnipdabeets
turnipdabeets marked this pull request as ready for review October 20, 2026 19:47
@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 20, 2026 19:47

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code looks good; no qualifying findings. Verdict: correct.

@turnipdabeets
turnipdabeets merged commit 4f38eb0 into main Oct 21, 2026
7 checks passed
@turnipdabeets
turnipdabeets deleted the posthog/capture-canonical-event-uuid branch October 21, 2026 14:25
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