You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Align Python /flags/?v=2 retry 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.py
uv run --extra test --extra dev python .github/scripts/check_public_api.py
uv run --extra test pytest posthog/test/test_request.py posthog/test/test_client.py
📝 Checklist
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.
If releasing new changes
Ran sampo add to 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 /flags transport retries, with default max retries set to 1, 0 disabling retries, and exponential backoff starting at 300ms.
Two tests (test_flags_retries_contract_http_status_errors and test_flags_does_not_retry_other_http_status_errors) iterate over status code lists with for … subTest rather than using @parameterized.expand, which is the team standard (see test_feature_flags_request_max_retries_is_forwarded added in this same PR for the correct pattern). Failures in subTest loops are harder to locate in CI output, and a future reader must scan the loop body to understand what inputs are covered. Both tests are good candidates for @parameterized.expand([(502,), (504,)]) and @parameterized.expand([(408,), (429,), (500,), (503,)]) respectively.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Addressed the Greptile feedback in fe937c6: converted the /flags HTTP status retry tests from subTest loops to @parameterized.expand, and also de-duplicated retry bookkeeping from the inline comment.
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
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.