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(cdp): return hidden templates on authenticated project list (#61992)

Meikel Ratzdc342f8b5000
diff --git a/products/cdp/backend/api/hog_function_template.py b/products/cdp/backend/api/hog_function_template.py
index 609886924f9b..4efde0c0a70b 100644
--- a/products/cdp/backend/api/hog_function_template.py
+++ b/products/cdp/backend/api/hog_function_template.py
@@ -145,8 +145,14 @@ class PublicHogFunctionTemplateViewSet(
if self.request.GET.get("template_id"):
queryset = queryset.filter(template_id=self.request.GET["template_id"])
- # Don't include deprecated or hidden templates when listing, regardless of mount
- queryset = queryset.exclude(status="deprecated").exclude(status="hidden")
+ queryset = queryset.exclude(status="deprecated")
+
+ # Hidden templates (e.g. template-posthog-capture, template-posthog-update-person-properties,
+ # email, twilio, webhook) are internal building blocks. The workflow editor needs them on
+ # the authenticated project mount to render action configuration; the frontend hides them
+ # from the destinations chooser separately. Only strip them from the anonymous catalog.
+ if self.request.path.startswith("/api/public_hog_function_templates"):
+ queryset = queryset.exclude(status="hidden")
return queryset
diff --git a/products/cdp/backend/api/test/test_hog_function_templates.py b/products/cdp/backend/api/test/test_hog_function_templates.py
index 3a60ccd71a4a..5576f08bddf2 100644
--- a/products/cdp/backend/api/test/test_hog_function_templates.py
+++ b/products/cdp/backend/api/test/test_hog_function_templates.py
@@ -305,7 +305,11 @@ class TestHogFunctionTemplates(ClickhouseTestMixin, APIBaseTest, QueryMatchingTe
retrieve_response = self.client.get(f"/api/projects/{self.team.id}/hog_function_templates/template-hidden")
assert retrieve_response.status_code in (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN)
- def test_hidden_templates_excluded_from_project_list(self):
+ def test_hidden_templates_included_in_project_list(self):
+ # Hidden templates are internal building blocks (e.g. template-posthog-capture,
+ # template-posthog-update-person-properties, email, twilio). The workflow editor pulls them
+ # via the authenticated project list to render action configuration; the destinations chooser
+ # filters them client-side. Excluding them server-side breaks workflows containing those steps.
HogFunctionTemplate.objects.create(
template_id="template-hidden",
sha="1.0.0",
@@ -322,6 +326,25 @@ class TestHogFunctionTemplates(ClickhouseTestMixin, APIBaseTest, QueryMatchingTe
response = self.client.get(f"/api/projects/{self.team.id}/hog_function_templates/")
assert response.status_code == status.HTTP_200_OK, response.json()
+ assert "template-hidden" in [template["id"] for template in response.json()["results"]]
+
+ def test_hidden_templates_excluded_from_public_catalog(self):
+ HogFunctionTemplate.objects.create(
+ template_id="template-hidden",
+ sha="1.0.0",
+ name="Hidden Template",
+ description="A hidden template",
+ code="return event",
+ code_language="hog",
+ inputs_schema={},
+ type="destination",
+ status="hidden",
+ category=["Other"],
+ free=True,
+ )
+
+ response = self.client.get("/api/public_hog_function_templates/")
+ assert response.status_code == status.HTTP_200_OK, response.json()
assert "template-hidden" not in [template["id"] for template in response.json()["results"]]
def _get_with_pak(self, suffix, scopes, scoped_teams=None):