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(api): Block people from creating hogql models (#79573)

Tomás Farías Santanaddf52cc62178
diff --git a/products/batch_exports/backend/api/batch_export.py b/products/batch_exports/backend/api/batch_export.py
index 8d971134072b..6beffb9aaaad 100644
--- a/products/batch_exports/backend/api/batch_export.py
+++ b/products/batch_exports/backend/api/batch_export.py
@@ -1169,6 +1169,26 @@ class BatchExportSerializer(serializers.ModelSerializer):
)
return filters
+ def validate_model(self, model) -> str:
+ if model == "hogql":
+ team_id = self.context["team_id"]
+ team = Team.objects.get(id=team_id)
+ if not posthoganalytics.feature_enabled(
+ "hogql-batch-exports",
+ str(team.uuid),
+ groups={"organization": str(team.organization.id)},
+ group_properties={
+ "organization": {
+ "id": str(team.organization.id),
+ "created_at": team.organization.created_at,
+ }
+ },
+ send_feature_flag_events=False,
+ ):
+ raise PermissionDenied("HogQL batch exports are not enabled for this team.")
+
+ return model
+
# TODO: could this be moved inside BatchExportDestinationSerializer::validate?
def validate_destination(self, destination_attrs: dict):
destination_type = destination_attrs["type"]