Skip to content

fix: generate UUID v7 by default#232

Draft
marandaneto wants to merge 2 commits into
mainfrom
fix/use-uuid-v7
Draft

fix: generate UUID v7 by default#232
marandaneto wants to merge 2 commits into
mainfrom
fix/use-uuid-v7

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

SDK-generated IDs should use UUID v7 so they are time-ordered. This updates the default UUID path used for event uuid values and personless distinct IDs created from request context, while preserving caller-provided UUIDs unchanged.

💚 How did you test it?

  • go test ./...

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

Implemented by a delegated coding agent from explicit maintainer direction to migrate SDK-generated UUIDs from v4/random to v7. Chose the existing github.com/google/uuid dependency's NewV7() API and kept explicit user-provided UUID behavior unchanged.

@marandaneto marandaneto self-assigned this Jun 19, 2026
@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
request_context_test.go:100-104
**Repeated UUID v7 assertion block**

The three-line pattern `uuid.Parse``require.NoError``require.Equal(t, uuid.Version(7), ...)` is duplicated verbatim at lines 100–104, 259–263, and 289–293. A small helper — e.g. `requireUUIDv7(t testing.TB, s string)` — would satisfy the OnceAndOnlyOnce principle and keep future version bumps to a single change site.

Reviews (1): Last reviewed commit: "fix: generate UUID v7 by default" | Re-trigger Greptile

Comment thread request_context_test.go Outdated
Comment thread message.go
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

posthog-go Compliance Report

Date: 2026-06-19 12:30:56 UTC
Duration: 3717754ms

⚠️ Some Tests Failed

32/45 tests passed, 13 failed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 610ms
Format Validation.Event Has Uuid 608ms
Format Validation.Event Has Lib Properties 608ms
Format Validation.Distinct Id Is String 608ms
Format Validation.Token Is Present 608ms
Format Validation.Custom Properties Preserved 608ms
Format Validation.Event Has Timestamp 608ms
Retry Behavior.Retries On 503 5613ms
Retry Behavior.Does Not Retry On 400 2611ms
Retry Behavior.Does Not Retry On 401 2611ms
Retry Behavior.Respects Retry After Header 5613ms
Retry Behavior.Implements Backoff 15609ms
Retry Behavior.Retries On 500 5612ms
Retry Behavior.Retries On 502 5613ms
Retry Behavior.Retries On 504 5613ms
Retry Behavior.Max Retries Respected 15624ms
Deduplication.Generates Unique Uuids 616ms
Deduplication.Preserves Uuid On Retry 5612ms
Deduplication.Preserves Uuid And Timestamp On Retry 10619ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5614ms
Deduplication.No Duplicate Events In Batch 612ms
Deduplication.Different Events Have Different Uuids 611ms
Compression.Sends Gzip When Enabled 608ms
Batch Format.Uses Proper Batch Structure 607ms
Batch Format.Flush With No Events Sends Nothing 606ms
Batch Format.Multiple Events Batched Together 611ms
Error Handling.Does Not Retry On 403 2610ms
Error Handling.Does Not Retry On 413 2610ms
Error Handling.Retries On 408 5613ms

Feature_Flags Tests

⚠️ 3/16 tests passed, 13 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 8ms
Request Payload.Flags Request Uses V2 Query Param 6ms
Request Payload.Flags Request Hits Flags Path Not Decide 6ms
Request Payload.Flags Request Omits Authorization Header 5ms
Request Payload.Token In Flags Body Matches Init 300710ms
Request Payload.Groups Round Trip 300996ms
Request Payload.Groups Default To Empty Object 301038ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 301011ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 301004ms
Request Payload.Disable Geoip Omitted Defaults To False 300949ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 301037ms
Request Lifecycle.No Flags Request On Init Alone 300953ms
Request Lifecycle.No Flags Request On Normal Capture 300984ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 301063ms
Request Lifecycle.Mock Response Value Is Returned To Caller 300986ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 301011ms

Failures

request_payload.request_with_person_properties_device_id

Field 'distinct_id' not found in /flags request body at path 'person_properties.distinct_id'. Available keys: ['$device_id']

request_payload.token_in_flags_body_matches_init

No error message

request_payload.groups_round_trip

No error message

request_payload.groups_default_to_empty_object

No error message

request_payload.person_properties_distinct_id_auto_populated_when_caller_omits_it

No error message

request_payload.disable_geoip_false_propagates_as_geoip_disable_false

No error message

request_payload.disable_geoip_omitted_defaults_to_false

No error message

request_payload.flag_keys_to_evaluate_contains_only_requested_key

No error message

request_lifecycle.no_flags_request_on_init_alone

No error message

request_lifecycle.no_flags_request_on_normal_capture

No error message

request_lifecycle.two_flag_calls_produce_two_remote_requests

No error message

request_lifecycle.mock_response_value_is_returned_to_caller

No error message

side_effect_events.get_feature_flag_captures_feature_flag_called_event

No error message

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.

1 participant