fix: retry event uploads on HTTP 408 (Request Timeout)#539
Conversation
The events retry set omitted 408 — a copy-paste guard from when the broader logs retry policy landed. But 408 is transient and retryable, the logs endpoint already retries it, and the SDK compliance contract now requires it. Add 408 to the events set and drop the now-obsolete asymmetry test. Closes #538
|
| @@ -317,22 +317,6 @@ internal class EndpointSpecTest { | |||
| http.shutdown() | |||
There was a problem hiding this comment.
The removed test also served as a guard for the negative cases — it asserted that
501, 505, and 599 are not retried by the events path. Now that it's gone, no test verifies that those codes still fall outside the retry set. If the policy were accidentally widened (e.g. a future copy-paste of the logs predicate), it would go unnoticed. Consider adding a complementary parameterised test for non-retriable codes alongside the new positive one.
Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog/src/test/java/com/posthog/internal/EndpointSpecTest.kt
Line: 317
Comment:
The removed test also served as a guard for the *negative* cases — it asserted that `501`, `505`, and `599` are not retried by the events path. Now that it's gone, no test verifies that those codes still fall outside the retry set. If the policy were accidentally widened (e.g. a future copy-paste of the logs predicate), it would go unnoticed. Consider adding a complementary parameterised test for non-retriable codes alongside the new positive one.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Good catch — restored the negative-case coverage in a focused events spec does not retry non-retriable status codes test (401/413/501/505/599 stay out of the events set), without re-introducing the 408-excluded assertion. Kept it as plain multi-assert @Test since the repo doesn't use parameterized runners.
posthog-android Compliance ReportDate: 2026-05-27 21:16:45 UTC
|
| Test | Status | Duration |
|---|---|---|
| Request Payload.Request With Person Properties Device Id | ❌ | 285ms |
| Request Payload.Flags Request Uses V2 Query Param | ❌ | 42ms |
| Request Payload.Flags Request Hits Flags Path Not Decide | ❌ | 36ms |
| Request Payload.Flags Request Omits Authorization Header | ❌ | 28ms |
| Request Payload.Token In Flags Body Matches Init | ❌ | 19ms |
| Request Payload.Groups Round Trip | ❌ | 16ms |
| Request Payload.Groups Default To Empty Object | ❌ | 14ms |
| Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It | ❌ | 16ms |
| Request Payload.Disable Geoip False Propagates As Geoip Disable False | ❌ | 19ms |
| Request Payload.Disable Geoip Omitted Defaults To False | ❌ | 15ms |
| Request Payload.Flag Keys To Evaluate Contains Only Requested Key | ❌ | 19ms |
| Request Lifecycle.No Flags Request On Init Alone | ❌ | 10ms |
| Request Lifecycle.No Flags Request On Normal Capture | ❌ | 2051ms |
| Request Lifecycle.Two Flag Calls Produce Two Remote Requests | ❌ | 14ms |
| Request Lifecycle.Mock Response Value Is Returned To Caller | ❌ | 14ms |
| Side Effect Events.Get Feature Flag Captures Feature Flag Called Event | ❌ | 14ms |
Failures
request_payload.request_with_person_properties_device_id
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.flags_request_uses_v2_query_param
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.flags_request_hits_flags_path_not_decide
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.flags_request_omits_authorization_header
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.token_in_flags_body_matches_init
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.groups_round_trip
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.groups_default_to_empty_object
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.person_properties_distinct_id_auto_populated_when_caller_omits_it
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.disable_geoip_false_propagates_as_geoip_disable_false
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.disable_geoip_omitted_defaults_to_false
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_payload.flag_keys_to_evaluate_contains_only_requested_key
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_lifecycle.no_flags_request_on_init_alone
Expected 0 /flags requests, got 1
request_lifecycle.no_flags_request_on_normal_capture
Expected 0 /flags requests, got 1
request_lifecycle.two_flag_calls_produce_two_remote_requests
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
request_lifecycle.mock_response_value_is_returned_to_caller
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
side_effect_events.get_feature_flag_captures_feature_flag_called_event
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
💡 Motivation and Context
HTTP 408 (Request Timeout) is transient and retryable, and the logs endpoint already retries it — but the events retry set omitted it (a copy-paste guard from when the broader logs policy landed). The SDK compliance contract now requires retrying 408 on events, so this adds it.
Closes #538. (posthog-ios counterpart: PostHog/posthog-ios#623.)
💚 How did you test it?
Added
retries on 408toPostHogQueueTest(mirrors the existing 503/500/502/504 cases). Removed the obsolete "events spec retry policy stays narrower than logs" test, which asserted 408 was excluded — events stays curated (still no501/505), it just gains408.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file