diff --git a/posthog/client.py b/posthog/client.py index eccaeae7..e3c14556 100644 --- a/posthog/client.py +++ b/posthog/client.py @@ -1814,7 +1814,7 @@ 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, @@ -1822,7 +1822,7 @@ def get_all_flags_and_payloads( 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, @@ -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 @@ -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. diff --git a/posthog/test/test_feature_flags.py b/posthog/test/test_feature_flags.py index 986b6cd9..f4733f81 100644 --- a/posthog/test/test_feature_flags.py +++ b/posthog/test/test_feature_flags.py @@ -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"} } @@ -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 = {