Repository navigation
fix: preserve person-processing policy over legacy properties - #985
dustinbyrne wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
PostHog Review · Standard · reviewed ecbb6a1: 1 Should fix.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
| if (result["process_person_profile"] == null) { | ||
| result["process_person_profile"] = false | ||
| result["process_person_profile"] = | ||
| (personProcessingPending && config?.personProfiles != PersonProfiles.NEVER) || hasPersonProcessing() |
There was a problem hiding this comment.
P2 · Preserve legacy processing overrides required by the capture contract
With PersonProfiles.ALWAYS, a caller's $process_person_profile: false now sends process_person_profile: true: optionsForEvent fills the canonical option, preventing the serializer's legacy fallback. This processes profiles against the caller's instruction and violates the canonical capture spec's precedence requirement; align the spec before removing this override.
There was a problem hiding this comment.
Intentional. It matches posthog-js and the stateful Rust client. The contract change goes into sdk-specs #146 first.
There was a problem hiding this comment.
Not approved — this change needs a human reviewer.
Re-add the stamphog label to request another review once you have addressed this.
The current-head reviewer raised a substantive precedence concern that the current code still exhibits, and no concern-free review covers the risky change. Address @PostHog's thread and request review from Anna Garcia or Vincent (Wen Yu) Ge before re-requesting.
- Author wrote 0% of the modified lines and has 21 merged PRs in these paths (familiarity MODERATE).
- PostHog Review (Standard) reviewed the current head: 1 finding, posted on the PR.
- posthog[bot] reviewed the current head.
- @PostHog on posthog/src/main/java/com/posthog/PostHog.kt: the concern about ignoring a caller's legacy false processing instruction remains reproducible. optionsForEvent supplies true under ALWAYS, and captureV1Json in internal/PostHogApi.kt only uses the legacy property when the canonical option is missing or null. Restore the required precedence or obtain independent acceptance of the contract change and resolve this thread before re-requesting.
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| every_file_attested | ✓ | not a bot PR |
| size | ✓ | 35L, 2F substantive, 285L/9F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1c-medium (285L, 9F, two-areas, fix) |
| stamphog 2.9.0 | .stamphog/policy.yml @ ecbb6a1 · reviewed head ecbb6a1 |
posthog-android Compliance ReportDate: 2026-11-16T23:27:22.523353+00:00
|
| Test | Status | Duration |
|---|---|---|
| Endpoint And Method.Targets V1 Endpoint | ✅ | 242ms |
| Endpoint And Method.Does Not Use Legacy Endpoints | ✅ | 19ms |
| Required Headers.Has Authorization Bearer Header | ✅ | 17ms |
| Required Headers.Has Content Type Json | ✅ | 18ms |
| Required Headers.Has Posthog Sdk Info Format | ✅ | 17ms |
| Required Headers.Has Posthog Attempt Header | ✅ | 18ms |
| Required Headers.Has Posthog Request Id | ✅ | 21ms |
| Required Headers.Has Posthog Request Timestamp | ✅ | 15ms |
| Required Headers.Has User Agent | ✅ | 15ms |
| Body Format.Body Has Created At And Batch | ✅ | 14ms |
| Body Format.No Api Key In Body | ✅ | 15ms |
| Body Format.No Sent At In Body | ✅ | 12ms |
| Event Format.Event Has Required Root Fields | ✅ | 16ms |
| Event Format.Event Uuid Is Valid | ✅ | 16ms |
| Event Format.Event Timestamp Is Rfc3339 | ✅ | 16ms |
| Event Format.Non Utc Event Timestamp Is Converted To Utc | ✅ | 15ms |
| Event Format.Distinct Id Is String | ✅ | 12ms |
| Event Format.Distinct Id At Root Not Properties | ✅ | 13ms |
| Event Format.Custom Properties Preserved | ✅ | 17ms |
| Event Format.Set Properties Preserved | ✅ | 15ms |
| Event Format.Set Once Properties Preserved | ✅ | 14ms |
| Event Format.Groups Properties Preserved | ✅ | 12ms |
| Event Format.Sdk Generates Uuid If Not Provided | ✅ | 16ms |
| Event Format.Event Has Required Root Fields Batch | ✅ | 19ms |
| Event Format.Event Uuid Is Valid Batch | ✅ | 18ms |
| Event Format.Event Timestamp Is Rfc3339 Batch | ✅ | 17ms |
| Event Format.Distinct Id Is String Batch | ✅ | 15ms |
| Event Format.Distinct Id At Root Not Properties Batch | ✅ | 17ms |
| Event Format.Custom Properties Preserved Batch | ✅ | 20ms |
| Event Format.Set Properties Preserved Batch | ✅ | 14ms |
| Event Format.Set Once Properties Preserved Batch | ✅ | 17ms |
| Event Format.Groups Properties Preserved Batch | ✅ | 17ms |
| Event Format.Sdk Generates Uuid If Not Provided Batch | ✅ | 17ms |
| Batch Behavior.Multiple Events In Single Batch | ✅ | 20ms |
| Batch Behavior.Batch Envelope Smoke | ✅ | 30ms |
| Batch Behavior.Flush With No Events Sends Nothing | ✅ | 16ms |
| Batch Behavior.Flush At Triggers Batch | ✅ | 1015ms |
| Batch Behavior.Created At Reflects Batch Creation Time | ✅ | 12ms |
| Deduplication.Generates Unique Uuids | ✅ | 21ms |
| Deduplication.Different Events Same Content Different Uuids | ✅ | 14ms |
| Deduplication.Preserves Uuid On Retry | ✅ | 7013ms |
| Deduplication.Preserves Timestamp On Retry | ✅ | 7014ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ✅ | 7023ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 23ms |
| Header Behavior On Retry.Attempt Header Starts At One | ✅ | 13ms |
| Header Behavior On Retry.Attempt Header Increments On Retry | ✅ | 12020ms |
| Header Behavior On Retry.Request Id Preserved On Retry | ✅ | 7015ms |
| Header Behavior On Retry.Different Requests Have Different Request Ids | ✅ | 2021ms |
| Header Behavior On Retry.Request Timestamp Changes On Retry | ✅ | 7014ms |
| Response Format Validation.Success Response Has Uuid Keyed Results | ✅ | 13ms |
| Response Format Validation.Success Response Has Ok For Each Event | ✅ | 16ms |
| Response Format Validation.Success No Retry After When All Ok | ✅ | 13ms |
| Response Format Validation.Success Retry After Present When Retry Events | ✅ | 2008ms |
| Response Format Validation.Success No Retry After When Drop Only | ✅ | 13ms |
| Response Format Validation.Response Echoes Request Id | ✅ | 10ms |
| Retry Behavior.Retries On 408 | ✅ | 7013ms |
| Retry Behavior.Retries On 500 | ✅ | 7013ms |
| Retry Behavior.Retries On 503 | ✅ | 7018ms |
| Retry Behavior.Retries On 504 | ✅ | 7013ms |
| Retry Behavior.Retries On 404 | ✅ | 7012ms |
| Retry Behavior.Retries On 429 | ✅ | 6013ms |
| Retry Behavior.Retries On 502 | ✅ | 7013ms |
| Retry Behavior.Retryable Errors Have Retry After | ✅ | 4011ms |
| Retry Behavior.Respects Retry After On Retryable Error | ✅ | 10012ms |
| Retry Behavior.Does Not Retry On 400 | ✅ | 4015ms |
| Retry Behavior.Does Not Retry On 401 | ✅ | 4013ms |
| Retry Behavior.Does Not Retry On 402 | ✅ | 4014ms |
| Retry Behavior.Does Not Retry On 413 | ✅ | 4014ms |
| Retry Behavior.Does Not Retry On 415 | ✅ | 4016ms |
| Retry Behavior.Non Retryable Errors Have No Retry After | ✅ | 4015ms |
| Retry Behavior.Implements Backoff | ✅ | 14021ms |
| Partial Batch Handling.Handles 200 Full Success | ✅ | 2012ms |
| Partial Batch Handling.Handles 200 With All Ok | ✅ | 3019ms |
| Partial Batch Handling.Does Not Retry Dropped Events | ✅ | 3016ms |
| Partial Batch Handling.Does Not Retry Warning Events | ✅ | 3017ms |
| Partial Batch Handling.Prunes Ok Events On Partial Retry | ✅ | 7014ms |
| Partial Batch Handling.Prunes Dropped Events On Partial Retry | ✅ | 7008ms |
| Partial Batch Handling.Retries Only Retry Events From Partial | ✅ | 7013ms |
| Partial Batch Handling.Partial Retry Preserves Uuids | ✅ | 7012ms |
| Partial Batch Handling.Partial Retry Attempt Header Increments | ✅ | 7014ms |
| Partial Batch Handling.Partial Retry Request Id Preserved | ✅ | 7014ms |
| Partial Batch Handling.Respects Retry After On Partial | ✅ | 7019ms |
| Partial Batch Handling.Unknown Result Treated As Terminal | ✅ | 3016ms |
| Partial Batch Handling.Mixed Ok Drop Warning No Retry | ✅ | 3019ms |
| Compression.Sends Gzip Content Encoding | ✅ | 11ms |
| Compression.No Content Encoding When Disabled | ✅ | 10ms |
| Compression.Compressed Body Is Decompressible | ✅ | 11ms |
| Error Handling.Does Not Retry On Unknown 4Xx | ✅ | 4013ms |
| Event Options.Cookieless Mode Override | ✅ | 11ms |
| Event Options.Disable Skew Correction Override | ✅ | 7ms |
| Event Options.Process Person Profile Override | ✅ | 8ms |
| Event Options.Product Tour Id Override | ✅ | 11ms |
| Event Options.Unset Options Omitted | ❌ | 8ms |
| Event Options.Options Override In Batch | ✅ | 13ms |
| Event Options.Unknown Option Passes Through | ✅ | 10ms |
| Event Options.Option Value Is Not Converted | ✅ | 8ms |
| Event Options.Lenient Bool Option Values Are Not Converted | ✅ | 9ms |
| Event Options.Option Wins Over Legacy Property | ✅ | 10ms |
| Event Options.Legacy Property Fills Unset Option | ✅ | 8ms |
| Event Options.Null Option Falls Back To Legacy Property | ✅ | 10ms |
| Property Layers.Caller Property Beats Registered Property | ✅ | 9ms |
| Property Layers.Before Send Runs Last | ✅ | 12ms |
| Fail Open.Empty Api Key Sends Nothing | ✅ | 3007ms |
| Fail Open.Personal Api Key Sends Nothing | ✅ | 3009ms |
| Geoip And Historical Migration.Historical Migration Absent By Default | ✅ | 10ms |
Failures
event_options.unset_options_omitted
Event option 'process_person_profile' should be absent, but options={'process_person_profile': True}
Capture_Ai_V1 Tests
View Details
| Test | Status | Duration |
|---|---|---|
| Endpoint And Method.Targets V1 Endpoint | ✅ | 10ms |
| Endpoint And Method.Does Not Use Legacy Endpoints | ✅ | 8ms |
| Endpoint And Method.Capture Does Not Reroute Ai Named Events | ✅ | 11ms |
| Endpoint And Method.Capture Ai Does Not Reroute Non Ai Events | ✅ | 9ms |
| Lane Isolation.Failing Ai Lane Does Not Delay Analytics | ✅ | 7021ms |
| Required Headers.Has Authorization Bearer Header | ✅ | 12ms |
| Required Headers.Has Content Type Json | ✅ | 12ms |
| Required Headers.Has Posthog Sdk Info Format | ✅ | 10ms |
| Required Headers.Has Posthog Attempt Header | ✅ | 11ms |
| Required Headers.Has Posthog Request Id | ✅ | 9ms |
| Required Headers.Has Posthog Request Timestamp | ✅ | 11ms |
| Required Headers.Has User Agent | ✅ | 9ms |
| Body Format.Body Has Created At And Batch | ✅ | 9ms |
| Body Format.No Api Key In Body | ✅ | 8ms |
| Body Format.No Sent At In Body | ✅ | 9ms |
| Event Format.Event Has Required Root Fields | ✅ | 10ms |
| Event Format.Event Uuid Is Valid | ✅ | 9ms |
| Event Format.Event Timestamp Is Rfc3339 | ✅ | 9ms |
| Event Format.Non Utc Event Timestamp Is Converted To Utc | ✅ | 12ms |
| Event Format.Distinct Id Is String | ✅ | 9ms |
| Event Format.Distinct Id At Root Not Properties | ✅ | 8ms |
| Event Format.Custom Properties Preserved | ✅ | 10ms |
| Event Format.Set Properties Preserved | ✅ | 12ms |
| Event Format.Set Once Properties Preserved | ✅ | 10ms |
| Event Format.Groups Properties Preserved | ✅ | 10ms |
| Event Format.Sdk Generates Uuid If Not Provided | ✅ | 10ms |
| Event Format.Event Has Required Root Fields Batch | ✅ | 11ms |
| Event Format.Event Uuid Is Valid Batch | ✅ | 14ms |
| Event Format.Event Timestamp Is Rfc3339 Batch | ✅ | 15ms |
| Event Format.Distinct Id Is String Batch | ✅ | 15ms |
| Event Format.Distinct Id At Root Not Properties Batch | ✅ | 15ms |
| Event Format.Custom Properties Preserved Batch | ✅ | 16ms |
| Event Format.Set Properties Preserved Batch | ✅ | 17ms |
| Event Format.Set Once Properties Preserved Batch | ✅ | 12ms |
| Event Format.Groups Properties Preserved Batch | ✅ | 12ms |
| Event Format.Sdk Generates Uuid If Not Provided Batch | ✅ | 14ms |
| Batch Behavior.Multiple Events In Single Batch | ✅ | 19ms |
| Batch Behavior.Batch Envelope Smoke | ✅ | 17ms |
| Batch Behavior.Flush At Triggers Batch | ✅ | 1011ms |
| Batch Behavior.Created At Reflects Batch Creation Time | ✅ | 11ms |
| Deduplication.Generates Unique Uuids | ✅ | 18ms |
| Deduplication.Different Events Same Content Different Uuids | ✅ | 10ms |
| Deduplication.Preserves Uuid On Retry | ✅ | 7010ms |
| Deduplication.Preserves Timestamp On Retry | ✅ | 7013ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ✅ | 7013ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 18ms |
| Header Behavior On Retry.Attempt Header Starts At One | ✅ | 9ms |
| Header Behavior On Retry.Attempt Header Increments On Retry | ✅ | 12018ms |
| Header Behavior On Retry.Request Id Preserved On Retry | ✅ | 7012ms |
| Header Behavior On Retry.Different Requests Have Different Request Ids | ✅ | 2024ms |
| Header Behavior On Retry.Request Timestamp Changes On Retry | ✅ | 7014ms |
| Response Format Validation.Success Response Has Uuid Keyed Results | ✅ | 11ms |
| Response Format Validation.Success Response Has Ok For Each Event | ✅ | 30ms |
| Response Format Validation.Success No Retry After When All Ok | ✅ | 17ms |
| Response Format Validation.Success Retry After Present When Retry Events | ✅ | 2006ms |
| Response Format Validation.Success No Retry After When Drop Only | ✅ | 11ms |
| Response Format Validation.Response Echoes Request Id | ✅ | 8ms |
| Retry Behavior.Retries On 408 | ✅ | 7009ms |
| Retry Behavior.Retries On 500 | ✅ | 7011ms |
| Retry Behavior.Retries On 503 | ✅ | 7017ms |
| Retry Behavior.Retries On 504 | ✅ | 7014ms |
| Retry Behavior.Retries On 404 | ✅ | 6011ms |
| Retry Behavior.Retries On 429 | ✅ | 7012ms |
| Retry Behavior.Retries On 502 | ✅ | 7013ms |
| Retry Behavior.Retryable Errors Have Retry After | ✅ | 4010ms |
| Retry Behavior.Respects Retry After On Retryable Error | ✅ | 10018ms |
| Retry Behavior.Does Not Retry On 400 | ✅ | 4014ms |
| Retry Behavior.Does Not Retry On 401 | ✅ | 4013ms |
| Retry Behavior.Does Not Retry On 402 | ✅ | 4011ms |
| Retry Behavior.Does Not Retry On 413 | ✅ | 4013ms |
| Retry Behavior.Does Not Retry On 415 | ✅ | 4011ms |
| Retry Behavior.Non Retryable Errors Have No Retry After | ✅ | 4012ms |
| Retry Behavior.Implements Backoff | ✅ | 14013ms |
| Partial Batch Handling.Handles 200 Full Success | ✅ | 2012ms |
| Partial Batch Handling.Handles 200 With All Ok | ✅ | 3015ms |
| Partial Batch Handling.Does Not Retry Dropped Events | ✅ | 3015ms |
| Partial Batch Handling.Does Not Retry Warning Events | ✅ | 3015ms |
| Partial Batch Handling.Prunes Ok Events On Partial Retry | ✅ | 7011ms |
| Partial Batch Handling.Prunes Dropped Events On Partial Retry | ✅ | 7012ms |
| Partial Batch Handling.Retries Only Retry Events From Partial | ✅ | 7012ms |
| Partial Batch Handling.Partial Retry Preserves Uuids | ✅ | 7010ms |
| Partial Batch Handling.Partial Retry Attempt Header Increments | ✅ | 7011ms |
| Partial Batch Handling.Partial Retry Request Id Preserved | ✅ | 7007ms |
| Partial Batch Handling.Respects Retry After On Partial | ✅ | 7016ms |
| Partial Batch Handling.Unknown Result Treated As Terminal | ✅ | 3015ms |
| Partial Batch Handling.Mixed Ok Drop Warning No Retry | ✅ | 3017ms |
| Compression.Sends Gzip Content Encoding | ✅ | 12ms |
| Compression.No Content Encoding When Disabled | ✅ | 9ms |
| Compression.Compressed Body Is Decompressible | ✅ | 8ms |
| Error Handling.Does Not Retry On Unknown 4Xx | ✅ | 4009ms |
| Event Options.Cookieless Mode Override | ✅ | 9ms |
| Event Options.Disable Skew Correction Override | ✅ | 9ms |
| Event Options.Process Person Profile Override | ✅ | 9ms |
| Event Options.Product Tour Id Override | ✅ | 9ms |
| Event Options.Unset Options Omitted | ❌ | 8ms |
| Event Options.Options Override In Batch | ✅ | 12ms |
| Event Options.Unknown Option Passes Through | ✅ | 10ms |
| Event Options.Option Value Is Not Converted | ✅ | 10ms |
| Event Options.Lenient Bool Option Values Are Not Converted | ✅ | 9ms |
| Event Options.Option Wins Over Legacy Property | ✅ | 8ms |
| Event Options.Legacy Property Fills Unset Option | ✅ | 7ms |
| Event Options.Null Option Falls Back To Legacy Property | ✅ | 7ms |
| Event Size.Event Over Ceiling Is Not Sent | ✅ | 3215ms |
| Event Size.Over Ceiling Drop Is Reported Or Logged Without Content | ✅ | 2034ms |
| Event Size.Batches Close Before Byte Target | ✅ | 6055ms |
| Geoip And Historical Migration.Historical Migration Absent By Default | ✅ | 10ms |
| Property Layers.Caller Property Beats Registered Property | ✅ | 8ms |
| Property Layers.Before Send Runs Last | ✅ | 9ms |
| Fail Open.Empty Api Key Sends Nothing | ✅ | 1007ms |
| Fail Open.Personal Api Key Sends Nothing | ✅ | 1005ms |
Failures
event_options.unset_options_omitted
Event option 'process_person_profile' should be absent, but options={'process_person_profile': True}
Feature_Flags Tests
✅ 17/17 tests passed
View Details
| Test | Status | Duration |
|---|---|---|
| Request Payload.Request With Person Properties Device Id | ✅ | 18ms |
| Request Payload.Flags Request Uses V2 Query Param | ✅ | 11ms |
| Request Payload.Flags Request Hits Flags Path Not Decide | ✅ | 9ms |
| Request Payload.Flags Request Omits Authorization Header | ✅ | 9ms |
| Request Payload.Token In Flags Body Matches Init | ✅ | 9ms |
| Request Payload.Groups Round Trip | ✅ | 12ms |
| Request Payload.Groups Default To Empty Object | ✅ | 11ms |
| Request Payload.Disable Geoip False Propagates As Geoip Disable False | ✅ | 11ms |
| Request Payload.Disable Geoip Omitted Defaults To False | ✅ | 10ms |
| Request Payload.Flag Keys To Evaluate Contains Only Requested Key | ✅ | 8ms |
| Request Lifecycle.No Flags Request On Init Alone | ✅ | 5ms |
| Request Lifecycle.No Flags Request On Normal Capture | ✅ | 8ms |
| Request Lifecycle.Two Flag Calls Produce Two Remote Requests | ✅ | 13ms |
| Request Lifecycle.Mock Response Value Is Returned To Caller | ✅ | 10ms |
| Retry Behavior.Retries Flags On 502 | ✅ | 311ms |
| Retry Behavior.Retries Flags On 504 | ✅ | 311ms |
| Side Effect Events.Get Feature Flag Captures Feature Flag Called Event | ✅ | 11ms |
|
Thanks for digging into this. The precedence here is intentional for 4.0: on client SDKs, values the caller passes or registers win over the SDK's own, and that includes |
| val result = eventOptions ?: mutableMapOf() | ||
| if (result["process_person_profile"] == null) { | ||
| result["process_person_profile"] = false | ||
| result["process_person_profile"] = |
There was a problem hiding this comment.
[question] Sending process_person_profile: true on every event fails the compliance harness's Event Options.Unset Options Omitted here. posthog-js and the stateful Rust client send it too. Do we update the harness, or fill only false?
| * says otherwise. Nothing is added otherwise: PostHog processes person profiles by default. | ||
| * The event's [options] over the wrapper-registered ones, filling a missing or null | ||
| * `process_person_profile` with the SDK's computed Boolean before `beforeSend`. Legacy | ||
| * `$process_person_profile` properties don't override this default. |
There was a problem hiding this comment.
[suggestion] $process_person_profile now never wins, but it stays in properties through beforeSend, so the hook sees two conflicting values. If the hook drops the option, the send-time lift in PostHogApi brings back the stale value. The backend v1 PRs (go#450, rs#363, python#1247, node#5712) strip it before the hook. Can we remove it from properties for every event where we fill the option?
💡 Motivation and Context
Correct person-processing precedence in the upcoming Android 4.0 capture path. A registered or caller legacy
$process_person_profilecould enable processing underNEVER, or disable it underALWAYS.Supply a canonical Boolean
process_person_profilefrom the SDK policy and current identity/processing state beforebeforeSend. Non-null canonical options (including wrapper-registered options for ordinary events) still override that default, and hooks retain the final say. Identity methods still ignore inherited registered processing settings and retain their existing mode gates. This affects the stateful core client used by Android and native wrappers; the separate stateless/server implementation is unchanged.Update capture KDoc, migration guidance, the existing 4.0 changeset, and wire-level tests. No public API signatures change.
Intentional specification divergence: the current client capture precedence requirement requires a caller legacy processing property to win even in
nevermode. This change deliberately makes SDK policy authoritative over that legacy property only; canonical options and hooks remain overrides. The spec needs separate alignment.Companion iOS change: PostHog/posthog-ios#1088.
💚 How did you test it?
make testJava: all 1,303 core tests in 67 classes pass, with no failures, errors or skips.make checkFormatandgit diff --check: pass.ALWAYS,NEVER, and anonymous/identified/processing-enabledIDENTIFIED_ONLY, with registered/caller legacy true and false and missing/null/explicit canonical options.📝 Checklist
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with Pi (GPT-6.1), a repository-isolated worker, read/edit tools, shell/Gradle/Make, Git and GitHub CLI. A fresh read-only reviewer inspected the paired native diffs. Human review is required, particularly for the intentional capture-spec divergence.