fix: stop duplicating distinct_id in flags person properties#195
fix: stop duplicating distinct_id in flags person properties#195marandaneto wants to merge 2 commits into
Conversation
posthog-php Compliance ReportDate: 2026-07-01 15:15:43 UTC
|
| Test | Status | Duration |
|---|---|---|
| Format Validation.Event Has Required Fields | ✅ | 12ms |
| Format Validation.Event Has Uuid | ✅ | 6ms |
| Format Validation.Event Has Lib Properties | ✅ | 6ms |
| Format Validation.Distinct Id Is String | ✅ | 6ms |
| Format Validation.Token Is Present | ✅ | 6ms |
| Format Validation.Custom Properties Preserved | ✅ | 6ms |
| Format Validation.Event Has Timestamp | ✅ | 5ms |
| Retry Behavior.Retries On 503 | ✅ | 5316ms |
| Retry Behavior.Does Not Retry On 400 | ✅ | 2010ms |
| Retry Behavior.Does Not Retry On 401 | ✅ | 2009ms |
| Retry Behavior.Respects Retry After Header | ✅ | 8012ms |
| Retry Behavior.Implements Backoff | ✅ | 15729ms |
| Retry Behavior.Retries On 500 | ✅ | 5115ms |
| Retry Behavior.Retries On 502 | ✅ | 5115ms |
| Retry Behavior.Retries On 504 | ✅ | 5115ms |
| Retry Behavior.Max Retries Respected | ✅ | 16530ms |
| Deduplication.Generates Unique Uuids | ✅ | 12ms |
| Deduplication.Preserves Uuid On Retry | ✅ | 5113ms |
| Deduplication.Preserves Uuid And Timestamp On Retry | ✅ | 10318ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ✅ | 5117ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 11ms |
| Deduplication.Different Events Have Different Uuids | ✅ | 8ms |
| Compression.Sends Gzip When Enabled | ✅ | 5ms |
| Batch Format.Uses Proper Batch Structure | ✅ | 6ms |
| Batch Format.Flush With No Events Sends Nothing | ✅ | 3ms |
| Batch Format.Multiple Events Batched Together | ✅ | 10ms |
| Error Handling.Does Not Retry On 403 | ✅ | 2008ms |
| Error Handling.Does Not Retry On 413 | ✅ | 2010ms |
| Error Handling.Retries On 408 | ✅ | 5115ms |
Feature_Flags Tests
View Details
| Test | Status | Duration |
|---|---|---|
| Request Payload.Request With Person Properties Device Id | ❌ | 7ms |
| Request Payload.Flags Request Uses V2 Query Param | ✅ | 5ms |
| Request Payload.Flags Request Hits Flags Path Not Decide | ✅ | 5ms |
| Request Payload.Flags Request Omits Authorization Header | ✅ | 4ms |
| Request Payload.Token In Flags Body Matches Init | ✅ | 5ms |
| Request Payload.Groups Round Trip | ✅ | 5ms |
| Request Payload.Groups Default To Empty Object | ✅ | 7ms |
| Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It | ❌ | 5ms |
| Request Payload.Disable Geoip False Propagates As Geoip Disable False | ✅ | 5ms |
| Request Payload.Disable Geoip Omitted Defaults To False | ✅ | 4ms |
| Request Payload.Flag Keys To Evaluate Contains Only Requested Key | ✅ | 5ms |
| Request Lifecycle.No Flags Request On Init Alone | ✅ | 2ms |
| Request Lifecycle.No Flags Request On Normal Capture | ✅ | 6ms |
| Request Lifecycle.Two Flag Calls Produce Two Remote Requests | ✅ | 7ms |
| Request Lifecycle.Mock Response Value Is Returned To Caller | ✅ | 5ms |
| Side Effect Events.Get Feature Flag Captures Feature Flag Called Event | ✅ | 7ms |
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.person_properties_distinct_id_auto_populated_when_caller_omits_it
Field 'distinct_id' not found in /flags request body at path 'person_properties.distinct_id'. Available keys: ['email']
|
💡 Motivation and Context
/flagsrequests already senddistinct_idat the top level. Automatically copying the same value intoperson_properties.distinct_idsends duplicated identity data and differs from the desired payload shape.This PR keeps the top-level
distinct_idand stops automatically injecting it intoperson_properties. Caller-provided person properties are still forwarded.💚 How did you test it?
vendor/bin/phpunit (tests passed; command exited 1 because PHPUnit reported no coverage driver plus warnings/deprecations)📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
This was implemented with pi in dedicated git worktrees. I changed the /flags request construction so SDKs keep the top-level distinct_id while no longer auto-copying it into person_properties; explicit caller-provided person_properties['distinct_id'] values are still preserved where covered.