Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions posthog/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,15 +1814,15 @@ def get_all_flags_and_payloads(
)
)

response, fallback_to_decide = self._get_all_flags_and_payloads_locally(
response, fallback_to_flags = self._get_all_flags_and_payloads_locally(
distinct_id,
groups=groups,
person_properties=person_properties,
group_properties=group_properties,
flag_keys_to_evaluate=flag_keys_to_evaluate,
)

if fallback_to_decide and not only_evaluate_locally:
if fallback_to_flags and not only_evaluate_locally:
try:
decide_response = self.get_flags_decision(
distinct_id,
Expand Down Expand Up @@ -1858,7 +1858,7 @@ def _get_all_flags_and_payloads_locally(

flags: dict[str, FlagValue] = {}
payloads: dict[str, str] = {}
fallback_to_decide = False
fallback_to_flags = False
# If loading in previous line failed
if self.feature_flags:
# Filter flags based on flag_keys_to_evaluate if provided
Expand Down Expand Up @@ -1886,19 +1886,19 @@ def _get_all_flags_and_payloads_locally(
payloads[flag["key"]] = matched_payload
except InconclusiveMatchError:
# No need to log this, since it's just telling us to fall back to `/flags`
fallback_to_decide = True
fallback_to_flags = True
except Exception as e:
self.log.exception(
f"[FEATURE FLAGS] Error while computing variant and payload: {e}"
)
fallback_to_decide = True
fallback_to_flags = True
else:
fallback_to_decide = True
fallback_to_flags = True

return {
"featureFlags": flags,
"featureFlagPayloads": payloads,
}, fallback_to_decide
}, fallback_to_flags

def _initialize_flag_cache(self, cache_url):
"""Initialize feature flag cache for graceful degradation during service outages.
Expand Down
4 changes: 2 additions & 2 deletions posthog/test/test_feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def test_flag_with_complex_definition(self, patch_get, patch_flags):

@mock.patch("posthog.client.flags")
@mock.patch("posthog.client.get")
def test_feature_flags_fallback_to_decide(self, patch_get, patch_flags):
def test_feature_flags_fallback_to_flags(self, patch_get, patch_flags):
patch_flags.return_value = {
"featureFlags": {"beta-feature": "alakazam", "beta-feature2": "alakazam2"}
}
Expand Down Expand Up @@ -431,7 +431,7 @@ def test_feature_flags_fallback_to_decide(self, patch_get, patch_flags):

@mock.patch("posthog.client.flags")
@mock.patch("posthog.client.get")
def test_feature_flags_dont_fallback_to_decide_when_only_local_evaluation_is_true(
def test_feature_flags_dont_fallback_to_flags_when_only_local_evaluation_is_true(
self, patch_get, patch_flags
):
patch_flags.return_value = {
Expand Down
Loading