Skip to content

fix: drop a 2xx batch without readable results and send crash-context person processing as an option - #990

Merged
turnipdabeets merged 1 commit into
fix/v4-v1-rubric-followupsfrom
fix/v4-v1-followups-2
Oct 29, 2026
Merged

turnipdabeets merged 1 commit into
fix/v4-v1-rubric-followupsfrom
fix/v4-v1-followups-2

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Two capture v1 gaps against the SDK spec (PostHog/sdk-specs#146), stacked on #989:

  • A 2xx whose body can't be read as {"results": {...}} was logged as delivered. The spec makes it a terminal failure of the whole batch. The queue outcome doesn't change (records are removed, not retried), but the debug log now counts the batch as dropped. The log stays content-free.
  • The crash-context snapshot still wrote the legacy $process_person_profile property, which the send then hoisted. The spec says SDK-internal code sets the process_person_profile option directly. The snapshot now saves it as options, and the crash and memory exception reporters pass it to the $exception. A crash saved by an older build still carries the property, which hoisting still handles.

Neither changes what reaches PostHog, so there's no changeset or migration-guide entry.

A whitespace-only token was also on the list, but PostHogConfig already trims the token, so the existing empty check disables the SDK (covered by noOpsSetupWhenProjectTokenIsEmpty). No change needed.

💚 How did you test it?

  • Updated malformedSuccessDropsBatch and crashContextSavesPersonlessOption. Both fail with the source changes reverted.
  • swift test --filter "PostHogCaptureV1|PostHogSDKTest|ErrorTracking": 153 tests pass.
  • Full make test: only PostHogStorageTest group-container cases and PostHogLogsQueueTest fail. Both fail on the base branch locally too (the logs ones are flaky).
  • The memory exception reporter assertion runs only on iOS 27 and wasn't run locally.

📝 Checklist

  • All commits are signed (see Commit signing)
  • 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.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Claude Code from a list of capture v1 spec discrepancies. The whitespace-token item was dropped after checking that PostHogConfig trims the token.

🤖 Generated with Claude Code

@turnipdabeets turnipdabeets self-assigned this Oct 29, 2026
@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 29, 2026 00:04
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

posthog-ios Compliance Report

Date: 2026-10-29T15:00:00.783667+00:00
Duration: 921764ms

⚠️ Some Tests Failed

214/219 tests passed, 5 failed


Capture_V1 Tests

⚠️ 99/101 tests passed, 2 failed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint ✅ 2933ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 2734ms
Required Headers.Has Authorization Bearer Header ✅ 2770ms
Required Headers.Has Content Type Json ✅ 2783ms
Required Headers.Has Posthog Sdk Info Format ✅ 2706ms
Required Headers.Has Posthog Attempt Header ✅ 2805ms
Required Headers.Has Posthog Request Id ✅ 2741ms
Required Headers.Has Posthog Request Timestamp ✅ 2822ms
Required Headers.Has User Agent ✅ 2835ms
Body Format.Body Has Created At And Batch ✅ 2785ms
Body Format.No Api Key In Body ✅ 2809ms
Body Format.No Sent At In Body ✅ 2779ms
Event Format.Event Has Required Root Fields ✅ 2767ms
Event Format.Event Uuid Is Valid ✅ 2777ms
Event Format.Event Timestamp Is Rfc3339 ✅ 313ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 2847ms
Event Format.Distinct Id Is String ✅ 2820ms
Event Format.Distinct Id At Root Not Properties ✅ 2772ms
Event Format.Custom Properties Preserved ✅ 2751ms
Event Format.Set Properties Preserved ✅ 2735ms
Event Format.Set Once Properties Preserved ✅ 2804ms
Event Format.Groups Properties Preserved ✅ 2715ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 2747ms
Event Format.Event Has Required Root Fields Batch ✅ 2754ms
Event Format.Event Uuid Is Valid Batch ✅ 2908ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 2839ms
Event Format.Distinct Id Is String Batch ✅ 2884ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 2918ms
Event Format.Custom Properties Preserved Batch ✅ 2817ms
Event Format.Set Properties Preserved Batch ✅ 2752ms
Event Format.Set Once Properties Preserved Batch ✅ 2877ms
Event Format.Groups Properties Preserved Batch ✅ 2891ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 2761ms
Batch Behavior.Multiple Events In Single Batch ✅ 2863ms
Batch Behavior.Batch Envelope Smoke ✅ 2810ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 327ms
Batch Behavior.Flush At Triggers Batch ✅ 1285ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 2810ms
Deduplication.Generates Unique Uuids ✅ 2908ms
Deduplication.Different Events Same Content Different Uuids ✅ 2910ms
Deduplication.Preserves Uuid On Retry ✅ 9190ms
Deduplication.Preserves Timestamp On Retry ✅ 5379ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7893ms
Deduplication.No Duplicate Events In Batch ✅ 2905ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 2656ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 16702ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 5415ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 7456ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 8894ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 2685ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 2776ms
Response Format Validation.Success No Retry After When All Ok ✅ 2808ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2737ms
Response Format Validation.Success No Retry After When Drop Only ✅ 2824ms
Response Format Validation.Response Echoes Request Id ✅ 2683ms
Retry Behavior.Retries On 408 ✅ 9323ms
Retry Behavior.Retries On 500 ✅ 9223ms
Retry Behavior.Retries On 503 ✅ 11747ms
Retry Behavior.Retries On 504 ✅ 5292ms
Retry Behavior.Retryable Errors Have Retry After ✅ 6233ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 8315ms
Retry Behavior.Does Not Retry On 400 ✅ 4784ms
Retry Behavior.Does Not Retry On 401 ✅ 4764ms
Retry Behavior.Does Not Retry On 402 ✅ 4787ms
Retry Behavior.Does Not Retry On 413 ✅ 4812ms
Retry Behavior.Does Not Retry On 415 ✅ 2367ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4733ms
Retry Behavior.Implements Backoff ✅ 19215ms
Retry Behavior.Max Retries Respected ❌ 21699ms
Partial Batch Handling.Handles 200 Full Success ✅ 4693ms
Partial Batch Handling.Handles 200 With All Ok ✅ 5897ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 5852ms
Partial Batch Handling.Does Not Retry Limited Events ✅ 5818ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7878ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7982ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7773ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7869ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7848ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 7835ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7868ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 5696ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry ✅ 5744ms
Compression.Sends Gzip Content Encoding ✅ 2760ms
Compression.No Content Encoding When Disabled ✅ 2657ms
Compression.Compressed Body Is Decompressible ✅ 283ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4878ms
Event Options.Cookieless Mode Override ✅ 282ms
Event Options.Disable Skew Correction Override ✅ 2800ms
Event Options.Process Person Profile Override ✅ 2855ms
Event Options.Product Tour Id Override ✅ 2764ms
Event Options.Unset Options Omitted ✅ 2715ms
Event Options.Options Override In Batch ✅ 2719ms
Event Options.Unknown Option Passes Through ✅ 2646ms
Event Options.Option Value Is Not Converted ✅ 2766ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 356ms
Event Options.Option Wins Over Legacy Property ✅ 2696ms
Event Options.Legacy Property Fills Unset Option ✅ 2725ms
Event Options.Null Option Falls Back To Legacy Property ✅ 2781ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties ✅ 2731ms
Geoip And Historical Migration.Historical Migration Set In Body ❌ 2765ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 435ms

Failures

retry_behavior.max_retries_respected

Expected 4 requests, got 5

geoip_and_historical_migration.historical_migration_set_in_body

Body missing 'historical_migration' field. Body keys: ['batch', 'created_at']

Capture_Ai_V1 Tests

⚠️ 98/101 tests passed, 3 failed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint ✅ 2665ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 2634ms
Endpoint And Method.Capture Does Not Reroute Ai Named Events ✅ 2781ms
Required Headers.Has Authorization Bearer Header ✅ 2679ms
Required Headers.Has Content Type Json ✅ 2728ms
Required Headers.Has Posthog Sdk Info Format ✅ 2842ms
Required Headers.Has Posthog Attempt Header ✅ 2821ms
Required Headers.Has Posthog Request Id ✅ 2762ms
Required Headers.Has Posthog Request Timestamp ✅ 2719ms
Required Headers.Has User Agent ✅ 384ms
Body Format.Body Has Created At And Batch ✅ 2673ms
Body Format.No Api Key In Body ✅ 2741ms
Body Format.No Sent At In Body ✅ 399ms
Event Format.Event Has Required Root Fields ✅ 2732ms
Event Format.Event Uuid Is Valid ✅ 2767ms
Event Format.Event Timestamp Is Rfc3339 ✅ 303ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 2693ms
Event Format.Distinct Id Is String ✅ 2735ms
Event Format.Distinct Id At Root Not Properties ✅ 2670ms
Event Format.Custom Properties Preserved ✅ 2697ms
Event Format.Set Properties Preserved ✅ 2691ms
Event Format.Set Once Properties Preserved ✅ 2804ms
Event Format.Groups Properties Preserved ✅ 2688ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 2732ms
Event Format.Capture Ai Keeps Supplied Uuid ❌ 122ms
Event Format.Event Has Required Root Fields Batch ❌ 2920ms
Event Format.Event Uuid Is Valid Batch ✅ 2870ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 2807ms
Event Format.Distinct Id Is String Batch ✅ 2875ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 2787ms
Event Format.Custom Properties Preserved Batch ✅ 2783ms
Event Format.Set Properties Preserved Batch ✅ 2846ms
Event Format.Set Once Properties Preserved Batch ✅ 2806ms
Event Format.Groups Properties Preserved Batch ✅ 2834ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 413ms
Batch Behavior.Multiple Events In Single Batch ✅ 2888ms
Batch Behavior.Batch Envelope Smoke ✅ 2862ms
Batch Behavior.Flush At Triggers Batch ✅ 1165ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 2804ms
Deduplication.Generates Unique Uuids ✅ 2910ms
Deduplication.Different Events Same Content Different Uuids ✅ 3215ms
Deduplication.Preserves Uuid On Retry ✅ 5384ms
Deduplication.Preserves Timestamp On Retry ✅ 8762ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7800ms
Deduplication.No Duplicate Events In Batch ✅ 2994ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 2833ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 16859ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 9261ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2573ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 9215ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 2826ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 3147ms
Response Format Validation.Success No Retry After When All Ok ✅ 3191ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2868ms
Response Format Validation.Success No Retry After When Drop Only ✅ 2786ms
Response Format Validation.Response Echoes Request Id ✅ 2750ms
Retry Behavior.Retries On 408 ✅ 9232ms
Retry Behavior.Retries On 500 ✅ 5396ms
Retry Behavior.Retries On 503 ✅ 11253ms
Retry Behavior.Retries On 504 ✅ 9167ms
Retry Behavior.Retryable Errors Have Retry After ✅ 6220ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10704ms
Retry Behavior.Does Not Retry On 400 ✅ 4788ms
Retry Behavior.Does Not Retry On 401 ✅ 4753ms
Retry Behavior.Does Not Retry On 402 ✅ 4714ms
Retry Behavior.Does Not Retry On 413 ✅ 4777ms
Retry Behavior.Does Not Retry On 415 ✅ 4764ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4659ms
Retry Behavior.Implements Backoff ✅ 21644ms
Retry Behavior.Max Retries Respected ❌ 15324ms
Partial Batch Handling.Handles 200 Full Success ✅ 4673ms
Partial Batch Handling.Handles 200 With All Ok ✅ 5882ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 5767ms
Partial Batch Handling.Does Not Retry Limited Events ✅ 5867ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7935ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7724ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7813ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7840ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7797ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 8015ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7821ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 5995ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry ✅ 5799ms
Compression.Sends Gzip Content Encoding ✅ 2818ms
Compression.No Content Encoding When Disabled ✅ 2821ms
Compression.Compressed Body Is Decompressible ✅ 255ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4750ms
Event Options.Cookieless Mode Override ✅ 2785ms
Event Options.Disable Skew Correction Override ✅ 2745ms
Event Options.Process Person Profile Override ✅ 2722ms
Event Options.Product Tour Id Override ✅ 267ms
Event Options.Unset Options Omitted ✅ 2806ms
Event Options.Options Override In Batch ✅ 399ms
Event Options.Unknown Option Passes Through ✅ 2760ms
Event Options.Option Value Is Not Converted ✅ 2769ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 2764ms
Event Options.Option Wins Over Legacy Property ✅ 2826ms
Event Options.Legacy Property Fills Unset Option ✅ 411ms
Event Options.Null Option Falls Back To Legacy Property ✅ 2768ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties ✅ 2786ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 2894ms

Failures

event_format.capture_ai_keeps_supplied_uuid

Expected last action result '0198c0de-0000-7000-8000-000000000abc', got '01a18826-608f-71fb-8c4d-f2e72ed59e38'

event_format.event_has_required_root_fields_batch

Expected 1 requests, got 2

retry_behavior.max_retries_respected

Expected 4 requests, got 5

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 2852ms
Request Payload.Flags Request Uses V2 Query Param ✅ 2830ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 2864ms
Request Payload.Flags Request Omits Authorization Header ✅ 2801ms
Request Payload.Token In Flags Body Matches Init ✅ 2851ms
Request Payload.Groups Round Trip ✅ 2815ms
Request Payload.Groups Default To Empty Object ✅ 2796ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 2837ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 2833ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 2845ms
Request Lifecycle.No Flags Request On Init Alone ✅ 60ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 2826ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 5504ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 2765ms
Retry Behavior.Retries Flags On 502 ✅ 2885ms
Retry Behavior.Retries Flags On 504 ✅ 2851ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 2923ms

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

… person processing as an option

Count a capture v1 2xx whose body can't be read as per-event results as a
dropped batch in the debug log, not as delivered. The records are still
removed and not retried.

Save person processing in the crash context as the process_person_profile
option instead of the legacy $process_person_profile property, and pass it
when the crash and memory exception reporters send the $exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@turnipdabeets
turnipdabeets merged commit 4177a3b into fix/v4-v1-rubric-followups Oct 29, 2026
43 checks passed
@turnipdabeets
turnipdabeets deleted the fix/v4-v1-followups-2 branch October 29, 2026 15:49
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