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(workflows): drop secret inputs when saving a workflow template (#116764)

Michael Reichenbach64be28c9b23c
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 42c00071d6b8..43533a24041f 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -639,6 +639,8 @@ SPECTACULAR_SETTINGS = {
"AggregationEnum": ["sum", "avg", "count", "min", "max", "p95", "rate", "increase", "histogram_quantile"],
# AutoresearchRun.Status and AutoresearchTrainingRun.Status share this set.
"ZendeskImportJobStatusEnum": "products.conversations.backend.models.zendesk_import_job.ZendeskImportJob.Status",
+ # Workflow steps and workflow template steps both take a field named `type` with this set.
+ "HogFlowActionTypeEnum": "products.workflows.backend.models.hog_flow.hog_flow.SUPPORTED_ACTION_TYPES",
#
# The published name is already derived by a different choice set, so the
# entry holds this one apart.
diff --git a/products/workflows/backend/presentation/views/hog_flow.py b/products/workflows/backend/presentation/views/hog_flow.py
index 55be1654e6b6..d300f2e83166 100644
--- a/products/workflows/backend/presentation/views/hog_flow.py
+++ b/products/workflows/backend/presentation/views/hog_flow.py
@@ -267,7 +267,6 @@ from products.workflows.backend.facade.workflows import (
PERSON_DEPENDENT_ACTION_TYPES,
ROW_SCOPED_TRIGGER_TYPES,
SUPPORTED_ACTION_TYPES,
- TRIGGER_TYPES,
WORKFLOW_FIELD_FILTER_PARAMS,
WORKFLOW_SAFE_INTERNAL_EVENTS,
WORKFLOW_TYPES,
@@ -298,6 +297,7 @@ from products.workflows.backend.presentation.views.hog_flow_batch_job import (
)
from products.workflows.backend.presentation.views.hog_flow_fields import (
HOG_FLOW_VARIABLES_MAX_BYTES,
+ HogFlowActionTypeField,
HogFlowMaskingSerializer,
HogFlowVariableSerializer,
)
@@ -1177,66 +1177,6 @@ class HogFlowActionConfigField(serializers.JSONField):
pass
-class HogFlowActionTypeField(serializers.ChoiceField):
- """A closed set of action types, rejected at write time rather than at run time.
-
- A type with no worker handler can never execute: it saves fine, then every run that reaches it
- dies with "Action type 'x' not supported", and unless the step sets on_error: continue everything
- downstream silently never happens. Keeping `choices` populated also means drf-spectacular emits
- the enum, so generated clients and MCP tools advertise the valid values instead of callers
- guessing them.
-
- ChoiceField's own invalid_choice message is run through str.format, which can't carry the JSON
- example below (its braces would be read as format placeholders), so the message is raised here.
- """
-
- def to_internal_value(self, data: Any) -> str:
- # isinstance before the membership test: self.choices is a dict, so `data in self.choices`
- # raises TypeError on an unhashable JSON object/array, which escapes DRF's validation stack
- # (it only catches ValidationError) and 500s the endpoint.
- if isinstance(data, str) and data in self.choices:
- return super().to_internal_value(data)
- raise serializers.ValidationError(
- f"Unsupported action type {self._describe(data)}. "
- f"Valid types are: {', '.join(SUPPORTED_ACTION_TYPES)}. "
- "Steps that act on PostHog data don't get a type of their own - they are type 'function' "
- f"with a template_id.{self._hint(data)}"
- )
-
- @staticmethod
- def _hint(data: Any) -> str:
- # The types actually seen in stored workflows cluster into a few mistakes, so point at the
- # step the caller was reaching for rather than repeating one example to everyone.
- if not isinstance(data, str):
- return ""
- lowered = data.lower()
- if lowered in TRIGGER_TYPES:
- hint = (
- f" '{data}' is a trigger type, not an action type: the trigger is a single action of "
- "type 'trigger' and its kind belongs in the workflow's trigger field."
- )
- if lowered == "webhook":
- hint += " To call an external endpoint from a step, use template_id 'template-webhook'."
- return hint
- if "person" in lowered or "propert" in lowered or "contact" in lowered:
- return (
- " To set person properties, use template_id 'template-posthog-update-person-properties' "
- "with inputs distinct_id, set_properties and set_once_properties."
- )
- if "webhook" in lowered or "http" in lowered or "request" in lowered:
- return " To call an external endpoint, use template_id 'template-webhook'."
- return ""
-
- @staticmethod
- def _describe(data: Any) -> str:
- # Echo the value back only when it's a short string. A non-string type is a malformed
- # payload, and interpolating a whole nested object into the message would put it in the
- # response and the logs behind it.
- if not isinstance(data, str):
- return f"(expected a string, got {type(data).__name__})"
- return f'"{data[:100]}"' if len(data) > 100 else f'"{data}"'
-
-
class HogFlowActionSerializer(serializers.Serializer):
# max_length bounds every downstream copy of the id (edges, action_redirects, worker cache);
# real ids are short generated slugs, so 200 is generous.
diff --git a/products/workflows/backend/presentation/views/hog_flow_fields.py b/products/workflows/backend/presentation/views/hog_flow_fields.py
index fe5aea523bab..d4eccf38e6d0 100644
--- a/products/workflows/backend/presentation/views/hog_flow_fields.py
+++ b/products/workflows/backend/presentation/views/hog_flow_fields.py
@@ -1,8 +1,10 @@
import json
+from typing import Any
from rest_framework import serializers
from products.cdp.backend.presentation.hog_functions import generate_template_bytecode
+from products.workflows.backend.facade.workflows import SUPPORTED_ACTION_TYPES, TRIGGER_TYPES
# Caps both the variable definitions on a workflow and the variable values a single run passes,
# so the two share one number instead of drifting. The runtime also checks dynamically set
@@ -55,3 +57,63 @@ class HogFlowMaskingSerializer(serializers.Serializer):
attrs["bytecode"] = generate_template_bytecode(attrs["hash"], input_collector=set())
return super().validate(attrs)
+
+
+class HogFlowActionTypeField(serializers.ChoiceField):
+ """A closed set of action types, rejected at write time rather than at run time.
+
+ A type with no worker handler can never execute: it saves fine, then every run that reaches it
+ dies with "Action type 'x' not supported", and unless the step sets on_error: continue everything
+ downstream silently never happens. Keeping `choices` populated also means drf-spectacular emits
+ the enum, so generated clients and MCP tools advertise the valid values instead of callers
+ guessing them.
+
+ ChoiceField's own invalid_choice message is run through str.format, which can't carry the JSON
+ example below (its braces would be read as format placeholders), so the message is raised here.
+ """
+
+ def to_internal_value(self, data: Any) -> str:
+ # isinstance before the membership test: self.choices is a dict, so `data in self.choices`
+ # raises TypeError on an unhashable JSON object/array, which escapes DRF's validation stack
+ # (it only catches ValidationError) and 500s the endpoint.
+ if isinstance(data, str) and data in self.choices:
+ return super().to_internal_value(data)
+ raise serializers.ValidationError(
+ f"Unsupported action type {self._describe(data)}. "
+ f"Valid types are: {', '.join(SUPPORTED_ACTION_TYPES)}. "
+ "Steps that act on PostHog data don't get a type of their own - they are type 'function' "
+ f"with a template_id.{self._hint(data)}"
+ )
+
+ @staticmethod
+ def _hint(data: Any) -> str:
+ # The types actually seen in stored workflows cluster into a few mistakes, so point at the
+ # step the caller was reaching for rather than repeating one example to everyone.
+ if not isinstance(data, str):
+ return ""
+ lowered = data.lower()
+ if lowered in TRIGGER_TYPES:
+ hint = (
+ f" '{data}' is a trigger type, not an action type: the trigger is a single action of "
+ "type 'trigger' and its kind belongs in the workflow's trigger field."
+ )
+ if lowered == "webhook":
+ hint += " To call an external endpoint from a step, use template_id 'template-webhook'."
+ return hint
+ if "person" in lowered or "propert" in lowered or "contact" in lowered:
+ return (
+ " To set person properties, use template_id 'template-posthog-update-person-properties' "
+ "with inputs distinct_id, set_properties and set_once_properties."
+ )
+ if "webhook" in lowered or "http" in lowered or "request" in lowered:
+ return " To call an external endpoint, use template_id 'template-webhook'."
+ return ""
+
+ @staticmethod
+ def _describe(data: Any) -> str:
+ # Echo the value back only when it's a short string. A non-string type is a malformed
+ # payload, and interpolating a whole nested object into the message would put it in the
+ # response and the logs behind it.
+ if not isinstance(data, str):
+ return f"(expected a string, got {type(data).__name__})"
+ return f'"{data[:100]}"' if len(data) > 100 else f'"{data}"'
diff --git a/products/workflows/backend/presentation/views/hog_flow_template.py b/products/workflows/backend/presentation/views/hog_flow_template.py
index d5461e487e89..3a7db1dacc58 100644
--- a/products/workflows/backend/presentation/views/hog_flow_template.py
+++ b/products/workflows/backend/presentation/views/hog_flow_template.py
@@ -29,8 +29,9 @@ from products.workflows.backend.facade.templates import (
list_templates,
update_template,
)
-from products.workflows.backend.facade.workflows import WORKFLOW_SAFE_INTERNAL_EVENTS
+from products.workflows.backend.facade.workflows import SUPPORTED_ACTION_TYPES, WORKFLOW_SAFE_INTERNAL_EVENTS
from products.workflows.backend.presentation.views.hog_flow_fields import (
+ HogFlowActionTypeField,
HogFlowMaskingSerializer,
HogFlowVariableSerializer,
)
@@ -84,7 +85,10 @@ class HogFlowTemplateActionSerializer(serializers.Serializer):
created_at = serializers.IntegerField(required=False)
updated_at = serializers.IntegerField(required=False)
filters = HogFunctionFiltersSerializer(required=False, default=None, allow_null=True)
- type = serializers.CharField(max_length=100)
+ type = HogFlowActionTypeField(
+ choices=SUPPORTED_ACTION_TYPES,
+ help_text="One of: " + " | ".join(SUPPORTED_ACTION_TYPES) + ".",
+ )
config = serializers.JSONField()
output_variable = serializers.JSONField(required=False, allow_null=True)
diff --git a/products/workflows/backend/services/hog_flow_templates.py b/products/workflows/backend/services/hog_flow_templates.py
index 3bf6f2899baa..4d9282cb32a9 100644
--- a/products/workflows/backend/services/hog_flow_templates.py
+++ b/products/workflows/backend/services/hog_flow_templates.py
@@ -12,6 +12,7 @@ from products.workflows.backend.facade.contracts import (
)
from products.workflows.backend.facade.enums import HogFlowTemplateExitCondition, HogFlowTemplateScope
from products.workflows.backend.models.hog_flow.hog_flow_template import HogFlowTemplate
+from products.workflows.backend.services.hog_flow_secrets import TemplateCache, strip_content_secrets
from products.workflows.backend.templates import get_global_template_by_id, load_global_templates
WRITABLE_TEMPLATE_FIELDS = frozenset(
@@ -68,8 +69,21 @@ def _visible_templates(team_id: int, organization_id: UUID) -> QuerySet[HogFlowT
)
+def _drop_secret_inputs(template: HogFlowTemplate, template_cache: TemplateCache) -> None:
+ # Other team or organization members read a template, and it has no encrypted column like a
+ # workflow, so the value of a secret input is dropped rather than stored. Reads drop it too,
+ # so a row that still holds a secret value never serves it.
+ stripped = strip_content_secrets({"actions": template.actions, "trigger": template.trigger}, template_cache)
+ template.actions = stripped["actions"]
+ template.trigger = stripped["trigger"]
+
+
def list_templates(*, team_id: int, organization_id: UUID) -> list[WorkflowTemplate]:
- return [_to_template(t) for t in _visible_templates(team_id, organization_id).order_by("-updated_at")]
+ template_cache: TemplateCache = {}
+ templates = list(_visible_templates(team_id, organization_id).order_by("-updated_at"))
+ for template in templates:
+ _drop_secret_inputs(template, template_cache)
+ return [_to_template(template) for template in templates]
def get_template(*, team_id: int, organization_id: UUID, template_id: str) -> WorkflowTemplate | None:
@@ -78,14 +92,19 @@ def get_template(*, team_id: int, organization_id: UUID, template_id: str) -> Wo
except ValueError:
return None
template = _visible_templates(team_id, organization_id).filter(id=template_uuid).first()
- return _to_template(template) if template is not None else None
+ if template is None:
+ return None
+ _drop_secret_inputs(template, template_cache={})
+ return _to_template(template)
def create_template(*, team_id: int, created_by_id: int, fields: Mapping[str, Any]) -> WorkflowTemplate:
values = {key: value for key, value in fields.items() if key in WRITABLE_TEMPLATE_FIELDS}
if not values.get("scope"):
values["scope"] = HogFlowTemplateScope.ONLY_TEAM
- template = HogFlowTemplate.objects.create(team_id=team_id, created_by_id=created_by_id, **values)
+ template = HogFlowTemplate(team_id=team_id, created_by_id=created_by_id, **values)
+ _drop_secret_inputs(template, template_cache={})
+ template.save()
return _to_template(template)
@@ -100,6 +119,7 @@ def update_template(
for key, value in fields.items():
if key in WRITABLE_TEMPLATE_FIELDS:
setattr(template, key, value)
+ _drop_secret_inputs(template, template_cache={})
template.team_id = team_id
template.save()
return _to_template(template)
diff --git a/products/workflows/backend/tests/api/test_hog_flow_template.py b/products/workflows/backend/tests/api/test_hog_flow_template.py
index 05bda0bad20f..e385ee83cfbc 100644
--- a/products/workflows/backend/tests/api/test_hog_flow_template.py
+++ b/products/workflows/backend/tests/api/test_hog_flow_template.py
@@ -1,3 +1,4 @@
+import json
from typing import Any
from posthog.test.base import APIBaseTest
@@ -55,6 +56,13 @@ class TestHogFlowTemplateAPI(APIBaseTest):
"required": False,
"default": {"Content-Type": "application/json"},
},
+ {
+ "key": "api_key",
+ "type": "string",
+ "label": "API key",
+ "required": False,
+ "secret": True,
+ },
],
type="destination",
status="stable",
@@ -124,6 +132,71 @@ class TestHogFlowTemplateAPI(APIBaseTest):
# Verify inputs are preserved - only url was provided in custom_inputs
assert function_action["config"]["inputs"] == {"url": {"value": "https://custom.example.com"}}
+ def _template_with_secret_inputs(self, secret: str) -> dict[str, Any]:
+ inputs = {"url": {"value": "https://custom.example.com"}, "api_key": {"value": secret}}
+ hog_flow_data = self._create_hog_flow_data(custom_inputs=inputs)
+ hog_flow_data["actions"][0]["config"] = {
+ "type": "webhook",
+ "template_id": "template-test-defaults",
+ "inputs": inputs,
+ }
+ return hog_flow_data
+
+ def test_template_never_stores_secret_inputs(self):
+ create = self.client.post(
+ f"/api/projects/{self.team.id}/hog_flow_templates",
+ self._template_with_secret_inputs("CREATE-SECRET"),
+ format="json",
+ )
+ assert create.status_code == 201, create.json()
+ template_id = create.json()["id"]
+
+ update = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flow_templates/{template_id}",
+ self._template_with_secret_inputs("UPDATE-SECRET"),
+ format="json",
+ )
+ assert update.status_code == 200, update.json()
+
+ stored = self.client.get(f"/api/projects/{self.team.id}/hog_flow_templates/{template_id}").json()
+ for body in (create.json(), update.json(), stored):
+ for action in body["actions"]:
+ assert action["config"]["inputs"] == {"url": {"value": "https://custom.example.com"}}
+ assert body["trigger"]["inputs"] == {"url": {"value": "https://custom.example.com"}}
+
+ def _template_stored_with_secrets(self) -> HogFlowTemplate:
+ stored = self._template_with_secret_inputs("STORED-SECRET")
+ return HogFlowTemplate.objects.create(
+ team=self.team,
+ name=stored["name"],
+ scope="team",
+ actions=stored["actions"],
+ trigger=stored["actions"][0]["config"],
+ )
+
+ def test_reading_a_template_stored_with_secrets_drops_them(self):
+ template = self._template_stored_with_secrets()
+
+ retrieved = self.client.get(f"/api/projects/{self.team.id}/hog_flow_templates/{template.id}").json()
+ listed = self.client.get(f"/api/projects/{self.team.id}/hog_flow_templates").json()
+
+ assert "STORED-SECRET" not in json.dumps([retrieved, listed])
+ assert retrieved["actions"][1]["config"]["inputs"] == {"url": {"value": "https://custom.example.com"}}
+
+ def test_scope_only_update_drops_secret_inputs_stored_before(self):
+ template = self._template_stored_with_secrets()
+
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flow_templates/{template.id}",
+ {"scope": "organization"},
+ format="json",
+ )
+
+ assert response.status_code == 200, response.json()
+ template.refresh_from_db()
+ assert template.scope == "organization"
+ assert "STORED-SECRET" not in json.dumps([template.actions, template.trigger])
+
def test_template_creation_with_multiple_function_actions(self):
"""Test that all function actions preserve their inputs when creating templates"""
trigger_action = {
@@ -220,44 +293,26 @@ class TestHogFlowTemplateAPI(APIBaseTest):
assert template.team_id == self.team.id
assert template.created_by == self.user
- def test_template_function_validation(self):
- """Test that function actions validate template_id exists"""
- trigger_action = {
- "id": "trigger_node",
- "name": "trigger_1",
- "type": "trigger",
- "config": {
- "type": "event",
- "filters": {
- "events": [{"id": "$pageview", "name": "$pageview", "type": "events", "order": 0}],
- },
- },
- }
-
- action = {
- "id": "action_1",
- "name": "action_1",
- "type": "function",
- "config": {
- "template_id": "missing",
- "inputs": {},
- },
- }
+ @parameterized.expand(
+ [
+ ("missing_template", "function", "missing", "actions__1__template_id", "Template not found"),
+ # A trigger kind sent as a step type skipped both the template check and secret stripping.
+ ("trigger_kind_as_step_type", "webhook", "template-test-defaults", "actions__1__type", "Unsupported"),
+ ]
+ )
+ def test_template_action_validation(
+ self, _name: str, action_type: str, template_id: str, expected_attr: str, expected_detail: str
+ ) -> None:
+ hog_flow_data = self._create_hog_flow_data(custom_inputs={"api_key": {"value": "SECRET"}})
+ hog_flow_data["actions"][1]["type"] = action_type
+ hog_flow_data["actions"][1]["config"]["template_id"] = template_id
- hog_flow_data = {
- "name": "Test Flow",
- "actions": [trigger_action, action],
- "scope": "team",
- }
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flow_templates", hog_flow_data, format="json")
- response = self.client.post(f"/api/projects/{self.team.id}/hog_flow_templates", hog_flow_data)
assert response.status_code == 400, response.json()
- assert response.json() == {
- "attr": "actions__1__template_id",
- "code": "invalid_input",
- "detail": "Template not found",
- "type": "validation_error",
- }
+ assert response.json()["attr"] == expected_attr
+ assert expected_detail in response.json()["detail"]
+ assert not HogFlowTemplate.objects.exists()
def test_template_scope_field(self):
"""Test that scope field can be set to team but not global (global templates are code-only)"""
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index 945de2e215e9..77e439fee78c 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -104,6 +104,35 @@ export interface HogFunctionFiltersApi {
bytecode_contract?: string
}
+/**
+ * * `trigger` - trigger
+ * * `function` - function
+ * * `function_email` - function_email
+ * * `function_sms` - function_sms
+ * * `function_push` - function_push
+ * * `delay` - delay
+ * * `wait_until_condition` - wait_until_condition
+ * * `wait_until_time_window` - wait_until_time_window
+ * * `conditional_branch` - conditional_branch
+ * * `random_cohort_branch` - random_cohort_branch
+ * * `exit` - exit
+ */
+export type HogFlowActionTypeEnumApi = (typeof HogFlowActionTypeEnumApi)[keyof typeof HogFlowActionTypeEnumApi]
+
+export const HogFlowActionTypeEnumApi = {
+ Trigger: 'trigger',
+ Function: 'function',
+ FunctionEmail: 'function_email',
+ FunctionSms: 'function_sms',
+ FunctionPush: 'function_push',
+ Delay: 'delay',
+ WaitUntilCondition: 'wait_until_condition',
+ WaitUntilTimeWindow: 'wait_until_time_window',
+ ConditionalBranch: 'conditional_branch',
+ RandomCohortBranch: 'random_cohort_branch',
+ Exit: 'exit',
+} as const
+
/**
* Custom action serializer for templates that skips input validation
* (since templates should have default/empty values).
@@ -121,8 +150,20 @@ export interface HogFlowTemplateActionApi {
created_at?: number
updated_at?: number
filters?: HogFunctionFiltersApi | null
- /** @maxLength 100 */
- type: string
+ /** One of: trigger | function | function_email | function_sms | function_push | delay | wait_until_condition | wait_until_time_window | conditional_branch | random_cohort_branch | exit.
+ *
+ * * `trigger` - trigger
+ * * `function` - function
+ * * `function_email` - function_email
+ * * `function_sms` - function_sms
+ * * `function_push` - function_push
+ * * `delay` - delay
+ * * `wait_until_condition` - wait_until_condition
+ * * `wait_until_time_window` - wait_until_time_window
+ * * `conditional_branch` - conditional_branch
+ * * `random_cohort_branch` - random_cohort_branch
+ * * `exit` - exit */
+ type: HogFlowActionTypeEnumApi
config: unknown
output_variable?: unknown
}
@@ -502,35 +543,6 @@ export interface HogFlowEdgeApi {
from: string
}
-/**
- * * `trigger` - trigger
- * * `function` - function
- * * `function_email` - function_email
- * * `function_sms` - function_sms
- * * `function_push` - function_push
- * * `delay` - delay
- * * `wait_until_condition` - wait_until_condition
- * * `wait_until_time_window` - wait_until_time_window
- * * `conditional_branch` - conditional_branch
- * * `random_cohort_branch` - random_cohort_branch
- * * `exit` - exit
- */
-export type HogFlowActionTypeEnumApi = (typeof HogFlowActionTypeEnumApi)[keyof typeof HogFlowActionTypeEnumApi]
-
-export const HogFlowActionTypeEnumApi = {
- Trigger: 'trigger',
- Function: 'function',
- FunctionEmail: 'function_email',
- FunctionSms: 'function_sms',
- FunctionPush: 'function_push',
- Delay: 'delay',
- WaitUntilCondition: 'wait_until_condition',
- WaitUntilTimeWindow: 'wait_until_time_window',
- ConditionalBranch: 'conditional_branch',
- RandomCohortBranch: 'random_cohort_branch',
- Exit: 'exit',
-} as const
-
/**
* Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel|internal-event, filters?}. An active event trigger must name at least one event, action or property filter; with filters.source 'person-updates' that means at least one property filter. internal-event requires filters.events naming one or more allowed event ids, and runs once for each matching event on the internal-events stream. Runs are person-less, so person-dependent steps are rejected. $slack_message_received takes filters: {properties: [<cond>]} over the message properties (channel, user, bot_id, text, subtype, is_thread_reply), and requires an exact-match channel filter; without one it runs on every message in every connected channel. $github_event_received takes filters: {properties: [<cond>]} over the delivery properties (repository, event_type, action, sender, bot_sender, own_app, author_association, actor_access, title, body, review_state, branch, repository_visibility), and requires exact-match repository and event_type filters; without them it runs on every delivery from every connected repository. webhook and manual triggers also require template_id: 'template-source-webhook', and tracking_pixel requires template_id: 'template-source-webhook-pixel'. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}, or {key: 'id', type: 'cohort', value: <cohort_id>, operator: 'in'} to reference a cohort. batch triggers may set filters.audience_type: 'persons' (default) or 'accounts'. An accounts audience fans out one run per customer analytics account and takes account filters instead: properties entries of type 'account_custom_property' (key = definition id), plus tag_names: [<str>], assignment_status: 'all'|'assigned'|'unassigned', and assigned_to_user_ids: [<int>] when assignment_status is 'assigned'. all_roles_unassigned remains accepted for workflows saved before assignment_status was added. function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. function_email also accepts tracking_enabled?: <bool> (default true) - when false, no open pixel is injected, links are not rewritten, and the send skips ESP-level open/click tracking, so opens and clicks are not recorded for that step (delivery/bounce/unsubscribe still are). Dictionary input values are template strings too — write booleans/numbers as single-expression templates ('{true}', '{42}'), which evaluate to the typed value. delay: waits a fixed span or until a per-person/-event date — set EXACTLY ONE of delay_duration or delay_until. {delay_duration: '<number><unit>'} where unit is s|m|h|d. Fractions OK ('1.5d'=36h). Per-unit max s<=60, m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. delay_until: {expression: '<SQL>', offset?: '<±number><unit>'} waits until the date expression evaluates to (an ISO string, unix seconds, or a date value all resolve to the same instant); offset is a signed duration shifting it ('-1d' a day before, '2h' two hours after). expression is compiled server-side, so any bytecode sent with it is discarded. A person property is person.properties.<key>; an event property is properties.<key>, as the 'event.' prefix resolves to nothing and aborts the run. Optional timezone (IANA name), use_person_timezone (read $geoip_time_zone) and fallback_timezone decide which zone a date with no offset of its own is read in; a date that states an offset, and unix seconds, ignore them. Default UTC. Optional sibling max_delay_duration (default 30d, same '<number><unit>' format) caps how far past the step's start the wait may run. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. random_cohort_branch: {cohorts: [{percentage: <number>, name?}, ...]}. Index N matches the 'branch' edge with index:N; percentages are relative weights, so they should sum to 100 but a total above or below that still splits traffic in the given proportions. wait_until_condition: {condition: {filters}, events?: [{filters: {events: [{id, name, type: 'events'}], actions?: [...]}, name?}], max_wait_duration: <duration>} (same rules as delay). Continues when condition.filters match OR any events entry fires; each events entry must target at least one event or action. On resolution (a condition match or any events entry firing) it advances via the 'branch' edge with index:0; the max_wait_duration timeout falls through the 'continue' edge. exit: {reason}.
*/
diff --git a/products/workflows/frontend/generated/api.zod.ts b/products/workflows/frontend/generated/api.zod.ts
index ab3b71794773..f3caf7fe9745 100644
--- a/products/workflows/frontend/generated/api.zod.ts
+++ b/products/workflows/frontend/generated/api.zod.ts
@@ -20,8 +20,6 @@ export const hogFlowTemplatesCreateBodyActionsItemNameMax = 400
export const hogFlowTemplatesCreateBodyActionsItemDescriptionDefault = ``
export const hogFlowTemplatesCreateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowTemplatesCreateBodyActionsItemTypeMax = 100
-
export const hogFlowTemplatesCreateBodyAbortActionMax = 400
export const HogFlowTemplatesCreateBody = /* @__PURE__ */ zod
@@ -130,7 +128,26 @@ export const HogFlowTemplatesCreateBody = /* @__PURE__ */ zod
zod.null(),
])
.optional(),
- type: zod.string().max(hogFlowTemplatesCreateBodyActionsItemTypeMax),
+ type: zod
+ .enum([
+ 'trigger',
+ 'function',
+ 'function_email',
+ 'function_sms',
+ 'function_push',
+ 'delay',
+ 'wait_until_condition',
+ 'wait_until_time_window',
+ 'conditional_branch',
+ 'random_cohort_branch',
+ 'exit',
+ ])
+ .describe(
+ '\* `trigger` - trigger\n\* `function` - function\n\* `function_email` - function_email\n\* `function_sms` - function_sms\n\* `function_push` - function_push\n\* `delay` - delay\n\* `wait_until_condition` - wait_until_condition\n\* `wait_until_time_window` - wait_until_time_window\n\* `conditional_branch` - conditional_branch\n\* `random_cohort_branch` - random_cohort_branch\n\* `exit` - exit'
+ )
+ .describe(
+ 'One of: trigger | function | function_email | function_sms | function_push | delay | wait_until_condition | wait_until_time_window | conditional_branch | random_cohort_branch | exit.\n\n\* `trigger` - trigger\n\* `function` - function\n\* `function_email` - function_email\n\* `function_sms` - function_sms\n\* `function_push` - function_push\n\* `delay` - delay\n\* `wait_until_condition` - wait_until_condition\n\* `wait_until_time_window` - wait_until_time_window\n\* `conditional_branch` - conditional_branch\n\* `random_cohort_branch` - random_cohort_branch\n\* `exit` - exit'
+ ),
config: zod.unknown(),
output_variable: zod.unknown().optional(),
})
@@ -166,8 +183,6 @@ export const hogFlowTemplatesUpdateBodyActionsItemNameMax = 400
export const hogFlowTemplatesUpdateBodyActionsItemDescriptionDefault = ``
export const hogFlowTemplatesUpdateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowTemplatesUpdateBodyActionsItemTypeMax = 100
-
export const hogFlowTemplatesUpdateBodyAbortActionMax = 400
export const HogFlowTemplatesUpdateBody = /* @__PURE__ */ zod
@@ -276,7 +291,26 @@ export const HogFlowTemplatesUpdateBody = /* @__PURE__ */ zod
zod.null(),
])
.optional(),
- type: zod.string().max(hogFlowTemplatesUpdateBodyActionsItemTypeMax),
+ type: zod
+ .enum([
+ 'trigger',
+ 'function',
+ 'function_email',
+ 'function_sms',
+ 'function_push',
+ 'delay',
+ 'wait_until_condition',
+ 'wait_until_time_window',
+ 'conditional_branch',
+ 'random_cohort_branch',
+ 'exit',
+ ])
+ .describe(
+ '\* `trigger` - trigger\n\* `function` - function\n\* `function_email` - function_email\n\* `function_sms` - function_sms\n\* `function_push` - function_push\n\* `delay` - delay\n\* `wait_until_condition` - wait_until_condition\n\* `wait_until_time_window` - wait_until_time_window\n\* `conditional_branch` - conditional_branch\n\* `random_cohort_branch` - random_cohort_branch\n\* `exit` - exit'
+ )
+ .describe(
+ 'One of: trigger | function | function_email | function_sms | function_push | delay | wait_until_condition | wait_until_time_window | conditional_branch | random_cohort_branch | exit.\n\n\* `trigger` - trigger\n\* `function` - function\n\* `function_email` - function_email\n\* `function_sms` - function_sms\n\* `function_push` - function_push\n\* `delay` - delay\n\* `wait_until_condition` - wait_until_condition\n\* `wait_until_time_window` - wait_until_time_window\n\* `conditional_branch` - conditional_branch\n\* `random_cohort_branch` - random_cohort_branch\n\* `exit` - exit'
+ ),
config: zod.unknown(),
output_variable: zod.unknown().optional(),
})
@@ -312,8 +346,6 @@ export const hogFlowTemplatesPartialUpdateBodyActionsItemNameMax = 400
export const hogFlowTemplatesPartialUpdateBodyActionsItemDescriptionDefault = ``
export const hogFlowTemplatesPartialUpdateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowTemplatesPartialUpdateBodyActionsItemTypeMax = 100
-
export const hogFlowTemplatesPartialUpdateBodyAbortActionMax = 400
export const HogFlowTemplatesPartialUpdateBody = /* @__PURE__ */ zod
@@ -428,7 +460,26 @@ export const HogFlowTemplatesPartialUpdateBody = /* @__PURE__ */ zod
zod.null(),
])
.optional(),
- type: zod.string().max(hogFlowTemplatesPartialUpdateBodyActionsItemTypeMax),
+ type: zod
+ .enum([
+ 'trigger',
+ 'function',
+ 'function_email',
+ 'function_sms',
+ 'function_push',
+ 'delay',
+ 'wait_until_condition',
+ 'wait_until_time_window',
+ 'conditional_branch',
+ 'random_cohort_branch',
+ 'exit',
+ ])
+ .describe(
+ '\* `trigger` - trigger\n\* `function` - function\n\* `function_email` - function_email\n\* `function_sms` - function_sms\n\* `function_push` - function_push\n\* `delay` - delay\n\* `wait_until_condition` - wait_until_condition\n\* `wait_until_time_window` - wait_until_time_window\n\* `conditional_branch` - conditional_branch\n\* `random_cohort_branch` - random_cohort_branch\n\* `exit` - exit'
+ )
+ .describe(
+ 'One of: trigger | function | function_email | function_sms | function_push | delay | wait_until_condition | wait_until_time_window | conditional_branch | random_cohort_branch | exit.\n\n\* `trigger` - trigger\n\* `function` - function\n\* `function_email` - function_email\n\* `function_sms` - function_sms\n\* `function_push` - function_push\n\* `delay` - delay\n\* `wait_until_condition` - wait_until_condition\n\* `wait_until_time_window` - wait_until_time_window\n\* `conditional_branch` - conditional_branch\n\* `random_cohort_branch` - random_cohort_branch\n\* `exit` - exit'
+ ),
config: zod.unknown(),
output_variable: zod.unknown().optional(),
})
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index f346df3948a3..fcbae6d5d8f8 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -55578,8 +55578,20 @@ export namespace Schemas {
created_at?: number;
updated_at?: number;
filters?: HogFunctionFilters | null;
- /** @maxLength 100 */
- type: string;
+ /** One of: trigger | function | function_email | function_sms | function_push | delay | wait_until_condition | wait_until_time_window | conditional_branch | random_cohort_branch | exit.
+ *
+ * * `trigger` - trigger
+ * * `function` - function
+ * * `function_email` - function_email
+ * * `function_sms` - function_sms
+ * * `function_push` - function_push
+ * * `delay` - delay
+ * * `wait_until_condition` - wait_until_condition
+ * * `wait_until_time_window` - wait_until_time_window
+ * * `conditional_branch` - conditional_branch
+ * * `random_cohort_branch` - random_cohort_branch
+ * * `exit` - exit */
+ type: HogFlowActionTypeEnum;
config: unknown;
output_variable?: unknown;
}