fix: Retry flags requests on 502 and 504#196
Merged
Merged
Conversation
|
Reviews (1): Last reviewed commit: "fix: retry flags requests on 502 and 504" | Re-trigger Greptile |
Contributor
posthog-php Compliance ReportDate: 2026-07-02 11:46:42 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
|
Reviews (2): Last reviewed commit: "chore: add flags retry changeset" | Re-trigger Greptile |
ioannisj
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Remote feature flag evaluation uses
/flags/?v=2. The SDK already retries transient curl/network failures usingfeature_flag_request_max_retries; this extends that same retry loop to retry HTTP 502 and 504 responses for the flags endpoint only.This does not change capture/batch retry behavior, and non-retryable flags HTTP statuses such as 408, 429, and 500 remain non-retryable.
💚 How did you test it?
composer install --no-interaction --prefer-dist./vendor/bin/phpunit --no-coverage --filter 'testFlagsRequest(RetriesHttp502And504|DoesNotRetryHttp502And504WhenConfiguredMaxRetriesIsZero|DoesNotRetryHttpStatusErrors|RetriesTransientCurlErrors|StopsAfterExhaustingTransientCurlErrorRetries|DoesNotRetryWhenConfiguredMaxRetriesIsZero|DoesNotRetryConnectionRefused)' test/FeatureFlagTest.php./vendor/bin/phpunit --no-coverage --filter 'testFlagsRequest(RetriesHttp502And504|DoesNotRetryHttp502And504WhenConfiguredMaxRetriesIsZero)' test/FeatureFlagTest.phpphp -l lib/Client.php && php -l lib/PostHog.php && php -l test/FeatureFlagTest.php./vendor/bin/phpcs lib/Client.php lib/PostHog.php test/FeatureFlagTest.php(0 errors; existing warnings remain)📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with an AI coding agent in response to a human-directed request. The change was kept to the flags request path: HTTP 502/504 now reuse the existing feature flag retry budget, while transient curl retry behavior is preserved and other HTTP status errors remain non-retryable.