fix(flags): retry flag requests on transient network errors#587
fix(flags): retry flag requests on transient network errors#587marandaneto wants to merge 6 commits into
Conversation
|
Reviews (1): Last reviewed commit: "fix: retry feature flag requests on netw..." | Re-trigger Greptile |
posthog-android Compliance ReportDate: 2026-06-26 15:09:10 UTC
|
| Test | Status | Duration |
|---|---|---|
| Format Validation.Event Has Required Fields | ✅ | 374ms |
| Format Validation.Event Has Uuid | ✅ | 28ms |
| Format Validation.Event Has Lib Properties | ✅ | 33ms |
| Format Validation.Distinct Id Is String | ✅ | 22ms |
| Format Validation.Token Is Present | ✅ | 24ms |
| Format Validation.Custom Properties Preserved | ✅ | 25ms |
| Format Validation.Event Has Timestamp | ✅ | 22ms |
| Retry Behavior.Retries On 503 | ✅ | 7029ms |
| Retry Behavior.Does Not Retry On 400 | ✅ | 4022ms |
| Retry Behavior.Does Not Retry On 401 | ✅ | 4024ms |
| Retry Behavior.Respects Retry After Header | ✅ | 7026ms |
| Retry Behavior.Implements Backoff | ✅ | 17034ms |
| Retry Behavior.Retries On 500 | ✅ | 7019ms |
| Retry Behavior.Retries On 502 | ✅ | 7019ms |
| Retry Behavior.Retries On 504 | ✅ | 7019ms |
| Retry Behavior.Max Retries Respected | ✅ | 17034ms |
| Deduplication.Generates Unique Uuids | ✅ | 38ms |
| Deduplication.Preserves Uuid On Retry | ✅ | 7014ms |
| Deduplication.Preserves Uuid And Timestamp On Retry | ✅ | 12030ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ✅ | 7014ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 34ms |
| Deduplication.Different Events Have Different Uuids | ✅ | 26ms |
| Compression.Sends Gzip When Enabled | ✅ | 19ms |
| Batch Format.Uses Proper Batch Structure | ✅ | 18ms |
| Batch Format.Flush With No Events Sends Nothing | ✅ | 11ms |
| Batch Format.Multiple Events Batched Together | ✅ | 32ms |
| Error Handling.Does Not Retry On 403 | ✅ | 4019ms |
| Error Handling.Does Not Retry On 413 | ❌ | 4017ms |
| Error Handling.Retries On 408 | ✅ | 5031ms |
Failures
error_handling.does_not_retry_on_413
Expected 1 requests, got 2
Feature_Flags Tests
View Details
| Test | Status | Duration |
|---|---|---|
| Request Payload.Request With Person Properties Device Id | ❌ | 36ms |
| Request Payload.Flags Request Uses V2 Query Param | ✅ | 21ms |
| Request Payload.Flags Request Hits Flags Path Not Decide | ✅ | 22ms |
| Request Payload.Flags Request Omits Authorization Header | ✅ | 24ms |
| Request Payload.Token In Flags Body Matches Init | ✅ | 22ms |
| Request Payload.Groups Round Trip | ✅ | 21ms |
| Request Payload.Groups Default To Empty Object | ❌ | 24ms |
| Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It | ❌ | 21ms |
| Request Payload.Disable Geoip False Propagates As Geoip Disable False | ❌ | 21ms |
| Request Payload.Disable Geoip Omitted Defaults To False | ❌ | 21ms |
| Request Payload.Flag Keys To Evaluate Contains Only Requested Key | ❌ | 19ms |
| Request Lifecycle.No Flags Request On Init Alone | ✅ | 14ms |
| Request Lifecycle.No Flags Request On Normal Capture | ✅ | 21ms |
| Request Lifecycle.Two Flag Calls Produce Two Remote Requests | ✅ | 2026ms |
| Request Lifecycle.Mock Response Value Is Returned To Caller | ✅ | 32ms |
| Side Effect Events.Get Feature Flag Captures Feature Flag Called Event | ✅ | 21ms |
Failures
request_payload.request_with_person_properties_device_id
Expected distinct_id='test_user_123', got '019f047a-3edf-7088-8695-45f79c740631'
request_payload.groups_default_to_empty_object
Field 'groups' not found in /flags request body at path 'groups'. Available keys: ['$anon_distinct_id', '$device_id', 'api_key', 'distinct_id', 'timezone', 'person_properties']
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: ['$lib', '$lib_version', 'email']
request_payload.disable_geoip_false_propagates_as_geoip_disable_false
Field 'geoip_disable' not found in /flags request body at path 'geoip_disable'. Available keys: ['$anon_distinct_id', '$device_id', 'api_key', 'distinct_id', 'timezone', 'person_properties']
request_payload.disable_geoip_omitted_defaults_to_false
Field 'geoip_disable' not found in /flags request body at path 'geoip_disable'. Available keys: ['$anon_distinct_id', '$device_id', 'api_key', 'distinct_id', 'timezone', 'person_properties']
request_payload.flag_keys_to_evaluate_contains_only_requested_key
Field 'flag_keys_to_evaluate' not found in /flags request body at path 'flag_keys_to_evaluate'. Available keys: ['$anon_distinct_id', '$device_id', 'api_key', 'distinct_id', 'timezone', 'person_properties']
161cf3e to
f322de9
Compare
|
Reviews (2): Last reviewed commit: "Merge branch 'main' into pi-flags-networ..." | Re-trigger Greptile |
💡 Motivation and Context
/flags/?v=2evaluation should tolerate transient network failures, but should not retry HTTP/API responses such as 408, 429, or 5xx.This PR adds bounded retry/backoff only for transient network failures (timeouts, connection resets/lost connections, and EOF-style failures) and keeps HTTP/API status errors terminal.
💚 How did you test it?
See the repo-specific command below.
📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented by pi after a maintainer-directed cross-SDK pass. The chosen policy is transient network-only retry/backoff for
/flags/?v=2; HTTP/API statuses remain non-retryable by design. Connection-refused failures also fail fast where the platform exposes that distinction.Tested with: