Skip to content

Commit cafc003

Browse files
committed
fix: Raise InconclusiveMatchError for missing group type mapping
When group_type_mapping is missing, the system should fall back to /decide/ endpoint rather than returning False. This matches the behavior of the original _compute_flag_locally method.
1 parent dd16231 commit cafc003

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

posthog/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,12 +1205,12 @@ def _compute_flag_locally(
12051205
self.log.warning(
12061206
f"[FEATURE FLAGS] Unknown group type index {aggregation_group_type_index} for feature flag {feature_flag['key']}"
12071207
)
1208-
# failover to `/decide/`
1208+
# failover to `/flags/`
12091209
raise InconclusiveMatchError("Flag has unknown group type index")
12101210

12111211
if group_name not in groups:
12121212
# Group flags are never enabled in `groups` aren't passed in
1213-
# don't failover to `/decide/`, since response will be the same
1213+
# don't failover to `/flags/`, since response will be the same
12141214
if warn_on_unknown_groups:
12151215
self.log.warning(
12161216
f"[FEATURE FLAGS] Can't compute group feature flag: {feature_flag['key']} without group names passed in"

posthog/dependency_graph.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,13 @@ def evaluate_flags_with_dependencies(
433433
_group_type_mapping = group_type_mapping or {}
434434

435435
group_name = _group_type_mapping.get(str(aggregation_group_type_index))
436-
if not group_name or group_name not in _groups:
437-
# Can't evaluate group flag without proper group info
436+
if not group_name:
437+
# Unknown group type index, failover to /flags/
438+
raise InconclusiveMatchError("Flag has unknown group type index")
439+
440+
if group_name not in _groups:
441+
# Group flags are never enabled if groups aren't passed in
442+
# Don't failover to /flags/, since response will be the same
438443
results[flag_key] = False
439444
dependency_graph.cache_result(flag_key, False)
440445
continue

posthog/test/test_feature_flags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def test_flag_group_properties(self, patch_get, patch_flags):
215215
)
216216
self.assertEqual(patch_flags.call_count, 0)
217217

218-
# Now group type mappings are gone, so fall back to /decide/
218+
# Now group type mappings are gone, so fall back to /flags/
219219
patch_flags.return_value = {
220220
"featureFlags": {"group-flag": "decide-fallback-value"}
221221
}

0 commit comments

Comments
 (0)