fix: Retry flags only on transport errors#708
Draft
marandaneto wants to merge 2 commits into
Draft
Conversation
Contributor
|
Reviews (1): Last reviewed commit: "fix: retry flags only on transport error..." | Re-trigger Greptile |
marandaneto
commented
Jun 28, 2026
Comment on lines
-44
to
-45
| # Status codes that indicate transient server errors worth retrying | ||
| RETRY_STATUS_FORCELIST = [408, 500, 502, 503, 504] |
Member
Author
There was a problem hiding this comment.
idk if that was intentional and why not all the other sdks do that, so i am assuming we should remove it and just retry for transient errors which is what all sdks should do
if all sdks should retry for those http errors as well, then i'd port this to all the other sdks
Member
Author
There was a problem hiding this comment.
@PostHog/team-feature-flags ?
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
Align Python
/flags/?v=2retry behavior with the other SDK fixes: retry only bounded network/transport/timeout failures, and do not retry HTTP/API status responses like 408, 429, or 5xx.This keeps transient network handling while avoiding repeated requests when PostHog has already returned an API response.
💚 How did you test it?
uv run --extra test --extra dev ruff check posthog/request.py posthog/client.py posthog/__init__.py posthog/test/test_request.py posthog/test/test_client.pyuv run --extra test --extra dev python .github/scripts/check_public_api.pyuv run --extra test pytest posthog/test/test_request.py posthog/test/test_client.py📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with pi. The retry policy was changed from urllib3 status-code retries to explicit
/flagstransport retries, with default max retries set to 1,0disabling retries, and exponential backoff starting at 300ms.