Skip to content

fix: correlate capture results for non-canonical event uuids - #358

Merged
eli-r-ph merged 2 commits into
v1from
v1-canonical-event-uuid
Oct 7, 2026
Merged

eli-r-ph merged 2 commits into
v1from
v1-canonical-event-uuid

Conversation

@eli-r-ph

@eli-r-ph eli-r-ph commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

The capture v1 endpoint parses each event uuid leniently (uppercase, no hyphens, braced, urn:uuid:), but keys the 200 results map by the canonical lowercase hyphenated form (response.rs).

makeUUID validated a caller-supplied uuid but returned it unchanged, and partitionResults looks results up by the exact string sent. For a non-canonical uuid the lookup missed, so the event was treated as accepted: a retry was never retried, a drop never reached Callback.Failure, and no success callback fired either.

  • makeUUID now returns the canonical form of a valid caller-supplied uuid.
  • prepareForSend canonicalizes the correlation key, because BeforeSend runs after makeUUID and may set any uuid form.

posthog-rs is not affected: its event uuid is a typed Uuid, which always serializes canonically.

💚 How did you test it?

  • New TestSendCorrelatesNonCanonicalUuid sends uppercase, unhyphenated, braced and urn:uuid: uuids to a test server that keys drop results canonically, and asserts the failure callback fires. It fails without the fix.
  • TestGeneratedUUIDsAreV7 asserts caller-supplied uuids are canonicalized.
  • go test ./... passes except TestOpenMachOUniversal, which also fails on unmodified v1 on my machine (macOS debug-image fixture).

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

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Cursor (Claude Opus) under the direction of the assignee. Found while aligning posthog-python's capture v1 result handling with this branch. "Missing from results means accepted" stays as is: with canonical keys, a 2xx always has an entry per event, so that branch only matters if the server breaks its contract.

@eli-r-ph

eli-r-ph commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Quick parity fix for this compared to other core backend SDKs I'm prepping for v1 release

@eli-r-ph
eli-r-ph marked this pull request as ready for review October 6, 2026 21:34
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 6, 2026 21:34

@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 UUID correlation fix looks correct. The malformed-wrapper fallback note below is non-blocking.

AI-assisted review.

Comment thread message.go Resolved
@eli-r-ph
eli-r-ph merged commit 75ebda0 into v1 Oct 7, 2026
32 checks passed
@eli-r-ph
eli-r-ph deleted the v1-canonical-event-uuid branch October 7, 2026 00: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