Skip to content

fix: Retry flags only on transport errors#708

Closed
marandaneto wants to merge 6 commits into
PostHog:mainfrom
marandaneto:pi-flags-network-retry-20260628
Closed

fix: Retry flags only on transport errors#708
marandaneto wants to merge 6 commits into
PostHog:mainfrom
marandaneto:pi-flags-network-retry-20260628

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

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.

@marandaneto marandaneto self-assigned this Jun 28, 2026
@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix: retry flags only on transport error..." | Re-trigger Greptile

Comment thread posthog/client.py Outdated
Comment thread posthog/test/test_client.py Outdated
Comment thread posthog/request.py
@marandaneto marandaneto requested a review from a team June 28, 2026 14:46
…y-20260628

# Conflicts:
#	posthog/request.py
@marandaneto

Copy link
Copy Markdown
Member Author

@PostHog/team-feature-flags ping

@marandaneto marandaneto force-pushed the pi-flags-network-retry-20260628 branch from c12e019 to 9748cb0 Compare July 2, 2026 08:45
@marandaneto marandaneto marked this pull request as ready for review July 2, 2026 09:01
@marandaneto marandaneto requested a review from a team as a code owner July 2, 2026 09:01
@marandaneto

Copy link
Copy Markdown
Member Author

this will require PostHog/posthog-sdk-test-harness#30 to be merged/released

@marandaneto marandaneto removed the request for review from a team July 2, 2026 09:02
@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "Merge branch 'main' into pi-flags-networ..." | Re-trigger Greptile

@ioannisj ioannisj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@marandaneto

Copy link
Copy Markdown
Member Author

Closing this fork PR in favor of the same-repository PR: #724

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants