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.

fix(taxonomy): scope enterprise property definition lookups by project (#107272)

posthog[bot]3ee314f3b042
diff --git a/ee/hogai/chat_agent/query_planner/toolkit.py b/ee/hogai/chat_agent/query_planner/toolkit.py
index 70f9e058d0e0..d4f561bcfbc8 100644
--- a/ee/hogai/chat_agent/query_planner/toolkit.py
+++ b/ee/hogai/chat_agent/query_planner/toolkit.py
@@ -202,7 +202,8 @@ class TaxonomyAgentToolkit:
)
qs = (
- EnterprisePropertyDefinition.objects.filter(team=self._team, type=property_type, name__in=names)
+ EnterprisePropertyDefinition.objects.alias(effective_project_id=effective_project_id_expr())
+ .filter(effective_project_id=self._team.project_id, type=property_type, name__in=names)
.exclude(description__isnull=True)
.exclude(description="")
)
diff --git a/ee/hogai/chat_agent/taxonomy/toolkit.py b/ee/hogai/chat_agent/taxonomy/toolkit.py
index 75dadea09c9c..defb61b9a7db 100644
--- a/ee/hogai/chat_agent/taxonomy/toolkit.py
+++ b/ee/hogai/chat_agent/taxonomy/toolkit.py
@@ -35,7 +35,11 @@ from posthog.taxonomy.property_access import restricted_property_names
from posthog.taxonomy.taxonomy import CORE_FILTER_DEFINITIONS_BY_GROUP, CoreFilterDefinition
from products.actions.backend.models.action import Action
-from products.event_definitions.backend.models.property_definition import PropertyDefinition, PropertyType
+from products.event_definitions.backend.models.property_definition import (
+ PropertyDefinition,
+ PropertyType,
+ effective_project_id_expr,
+)
from ee.hogai.chat_agent.taxonomy.format import (
enrich_props_with_descriptions,
@@ -232,7 +236,8 @@ class TaxonomyAgentToolkit:
)
qs = (
- EnterprisePropertyDefinition.objects.filter(team=self._team, type=property_type, name__in=names)
+ EnterprisePropertyDefinition.objects.alias(effective_project_id=effective_project_id_expr())
+ .filter(effective_project_id=self._team.project_id, type=property_type, name__in=names)
.exclude(description__isnull=True)
.exclude(description="")
)
diff --git a/posthog/api/event.py b/posthog/api/event.py
index bc5ade188f66..72d724fbc303 100644
--- a/posthog/api/event.py
+++ b/posthog/api/event.py
@@ -54,6 +54,8 @@ from posthog.rate_limit import (
from posthog.taxonomy.taxonomy import CORE_FILTER_DEFINITIONS_BY_GROUP
from posthog.utils import convert_property_value, flatten, refresh_requested_by_client, relative_date_parse
+from products.event_definitions.backend.models.property_definition import effective_project_id_expr
+
tracer = trace.get_tracer(__name__)
EVENT_VALUES_COUNTER = Counter(
@@ -674,12 +676,16 @@ class EventViewSet(
try:
from ee.models.property_definition import EnterprisePropertyDefinition
- property_is_hidden = EnterprisePropertyDefinition.objects.filter(
- team=team,
- name=key,
- type=PropertyDefinition.Type.EVENT.value,
- hidden=True,
- ).exists()
+ property_is_hidden = (
+ EnterprisePropertyDefinition.objects.alias(effective_project_id=effective_project_id_expr())
+ .filter(
+ effective_project_id=team.project_id,
+ name=key,
+ type=PropertyDefinition.Type.EVENT.value,
+ hidden=True,
+ )
+ .exists()
+ )
except ImportError:
# Enterprise features not available, continue normally
pass