Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(flags): point mcp merge helper at its backend drift guard (#98852)

Phil Haacka043fa01eee7
diff --git a/services/mcp/src/tools/featureFlags/preserveGroupTargeting.ts b/services/mcp/src/tools/featureFlags/preserveGroupTargeting.ts
index e36862165e27..3c499a59a934 100644
--- a/services/mcp/src/tools/featureFlags/preserveGroupTargeting.ts
+++ b/services/mcp/src/tools/featureFlags/preserveGroupTargeting.ts
@@ -122,6 +122,7 @@ function mergeProperty(
if (!isPresentType(out.type) && existingProp && isPresentType(existingProp.type)) {
// Leaving the type unset makes the API report the property the agent actually
// sent. Restoring `group` here would name fields the agent never sent.
+ // `!== 'group'` relies on the same complement rule. See mergeConditionGroup.
if (canCarryGroupTargeting || existingProp.type !== 'group') {
out.type = existingProp.type
}
@@ -161,6 +162,10 @@ function mergeConditionGroup(
// One explicit person, cohort, or flag property stops this set from keeping or
// gaining group targeting. An explicit incoming group index still wins, and the API
// then reports the contradiction in the agent's own payload.
+ // `!== 'group'` is the complement of PERSON_AGGREGATED_PROPERTY_TYPES in
+ // filters_validation.py. It holds only while 'group' is the sole type outside that
+ // tuple. A Python test asserts that:
+ // products/feature_flags/backend/test/test_filters_validation.py
const hasExplicitNonGroupProperty =
Array.isArray(incoming.properties) &&
incoming.properties.some((p) => isPresentType(p?.type) && p.type !== 'group')