-
Notifications
You must be signed in to change notification settings - Fork 69
fix: Retry flags only on transport errors #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -984,6 +984,21 @@ def test_basic_capture_with_feature_flags_returns_active_only(self, patch_flags) | |
| device_id=None, | ||
| ) | ||
|
|
||
| @mock.patch("posthog.client.flags") | ||
| def test_feature_flags_request_max_retries_is_forwarded_when_configured( | ||
| self, patch_flags | ||
| ): | ||
| patch_flags.return_value = {"featureFlags": {}, "featureFlagPayloads": {}} | ||
| client = Client( | ||
| FAKE_TEST_API_KEY, | ||
| feature_flags_request_max_retries=0, | ||
| personal_api_key=FAKE_TEST_API_KEY, | ||
| ) | ||
|
|
||
| client.get_all_flags("distinct_id") | ||
|
|
||
| self.assertEqual(patch_flags.call_args.kwargs["max_retries"], 0) | ||
|
Comment on lines
+987
to
+1000
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Context Used: Do not attempt to comment on incorrect alphabetica... (source) |
||
|
|
||
| @mock.patch("posthog.client.flags") | ||
| def test_basic_capture_with_feature_flags_and_disable_geoip_returns_correctly( | ||
| self, patch_flags | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flag_request_optionsdict and its conditional guard are superfluous.flags()already defaults toDEFAULT_FEATURE_FLAGS_REQUEST_MAX_RETRIES, so passing the stored value unconditionally produces identical behaviour for every configuration — but is simpler and more obviously correct. The extra dict and branch also make the default code path invisible to tests:patch_flags.call_args.kwargs["max_retries"]would raiseKeyErrorwhen the default is in use, forcing the test to cover only the non-default path.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!