fix: no-op flag helpers on API errors#639
Open
marandaneto wants to merge 2 commits into
Open
Conversation
Contributor
posthog-python Compliance ReportDate: 2026-06-01 07:36:11 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
|
32f6735 to
8ca7c5b
Compare
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
posthog/test/test_client.py:107-120
**Non-parameterized test for multiple helpers**
The test bundles four independent assertions in one method, so a failure in the first assertion (e.g. `get_flags_decision`) silences the remaining three. The codebase already uses both `@parameterized.expand` and `subTest` loops for exactly this scenario — see the `test_methods_handle_exceptions` test at line 2825 for a close parallel. Using `subTest` (or `@parameterized.expand`) would let all four helpers run independently and report individually, which is the team's stated preference for parameterised tests.
Reviews (1): Last reviewed commit: "fix: preserve flag error handling on fla..." | Re-trigger Greptile |
8ca7c5b to
ac6b054
Compare
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
The Python Client-only feature flag helpers should return default values instead of raising when
/flagsfails because the SDK is non-operational, for example due to an invalid non-empty project API key.Changes:
Client.get_flags_decision()and return an empty normalized flags response.get_flags_decision()(get_feature_variants,get_feature_payloads, andget_feature_flags_and_payloads).💚 How did you test it?
uv run pytest posthog/test/test_client.py -q📝 Checklist
If releasing new changes
sampo addto generate a changeset file