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): reject unknown hogflow action types at the API boundary (#75546)

Daniel Marchukffffc6283000
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.py
index 05d9970b5cdf..79a2b38acc96 100644
--- a/products/workflows/backend/api/hog_flow.py
+++ b/products/workflows/backend/api/hog_flow.py
@@ -91,6 +91,8 @@ from products.workflows.backend.api.publish_impact import build_publish_impact
from products.workflows.backend.models.hog_flow.hog_flow import (
BILLABLE_ACTION_TYPES,
PERSON_DEPENDENT_ACTION_TYPES,
+ SUPPORTED_ACTION_TYPES,
+ TRIGGER_TYPES,
HogFlow,
)
from products.workflows.backend.models.hog_flow_batch_job import HogFlowBatchJob
@@ -598,6 +600,66 @@ 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.
@@ -615,12 +677,9 @@ class HogFlowActionSerializer(serializers.Serializer):
filters = HogFunctionFiltersSerializer(
required=False, default=None, allow_null=True, help_text="Property filters gating this action."
)
- type = serializers.CharField(
- max_length=100,
- help_text=(
- "trigger | function | function_email | function_sms | delay | "
- "conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit."
- ),
+ type = HogFlowActionTypeField(
+ choices=SUPPORTED_ACTION_TYPES,
+ help_text="One of: " + " | ".join(SUPPORTED_ACTION_TYPES) + ".",
)
config = HogFlowActionConfigField(
help_text=(
diff --git a/products/workflows/backend/api/test/test_hog_flow.py b/products/workflows/backend/api/test/test_hog_flow.py
index a8bbeaf0eff2..76aab6e8d080 100644
--- a/products/workflows/backend/api/test/test_hog_flow.py
+++ b/products/workflows/backend/api/test/test_hog_flow.py
@@ -24,8 +24,12 @@ from posthog.test.fixtures import create_app_metric2
from products.actions.backend.models.action import Action
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
from products.cohorts.backend.models.cohort import Cohort
-from products.workflows.backend.api.hog_flow import _should_validate_strictly, mint_audience_confirm_token
-from products.workflows.backend.models.hog_flow.hog_flow import HogFlow
+from products.workflows.backend.api.hog_flow import (
+ HogFlowActionSerializer,
+ _should_validate_strictly,
+ mint_audience_confirm_token,
+)
+from products.workflows.backend.models.hog_flow.hog_flow import SUPPORTED_ACTION_TYPES, HogFlow
from products.workflows.backend.models.hog_flow_batch_job.hog_flow_batch_job import HogFlowBatchJob
webhook_template = MOCK_NODE_TEMPLATES[0]
@@ -3614,6 +3618,98 @@ class TestHogFlowAPI(APIBaseTest):
if expected_error:
assert response.json()["detail"] == expected_error
+ @parameterized.expand(
+ [
+ # Every unsupported type used to get the same person-properties example, so most of the
+ # stored offenders (webhooks, filters) were pointed at the wrong step.
+ ("person_property_family", "set_person_property", "template-posthog-update-person-properties"),
+ ("contact_family", "contact_update", "template-posthog-update-person-properties"),
+ ("outbound_call", "http", "template-webhook"),
+ # 'webhook' is a trigger kind, so the message has to say which of the two was confused.
+ ("trigger_kind", "webhook", "is a trigger type"),
+ ]
+ )
+ def test_rejection_points_at_the_step_the_caller_meant(self, _name, action_type, expected):
+ field = HogFlowActionSerializer().fields["type"]
+ with self.assertRaises(Exception) as ctx:
+ field.to_internal_value(action_type)
+ assert expected in str(ctx.exception), str(ctx.exception)
+
+ @parameterized.expand(
+ [
+ # A step type invented from the name of a real feature ("Update person properties", which
+ # is really type 'function' + template-posthog-update-person-properties).
+ ("invented_from_a_feature_name", "update_person_properties"),
+ ("plausible_but_unhandled", "send_email"),
+ ("nonsense", "zzz_not_a_type"),
+ ]
+ )
+ def test_unsupported_action_type_is_rejected_at_write_time(self, _name, action_type):
+ # An action type with no worker handler can never run: it used to save fine and then kill
+ # every run that reached it, silently dropping every step downstream.
+ hog_flow, _ = self._create_hog_flow_with_action({})
+ hog_flow["actions"][1] = {
+ "id": "bad_node",
+ "name": "Tag person",
+ "type": action_type,
+ "config": {"properties": {"onboarding_variant": "A"}},
+ }
+
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+
+ assert response.status_code == 400, response.json()
+ detail = response.json()["detail"]
+ assert action_type in detail
+ # The valid set is what every caller needs; the template suggestion is per-type and is
+ # covered by test_rejection_points_at_the_step_the_caller_meant.
+ assert "Valid types are:" in detail
+ assert "wait_until_condition" in detail
+
+ @parameterized.expand(
+ [
+ ("object", {}),
+ ("populated_object", {"a": 1}),
+ ("array", []),
+ ("array_of_a_valid_type", ["trigger"]),
+ ("integer", 123),
+ ("null", None),
+ ]
+ )
+ def test_non_string_action_type_is_a_400_not_a_500(self, _name, action_type):
+ # Closing the type field over a dict of choices makes an unhashable value (a JSON object or
+ # array) raise TypeError out of the membership test. DRF only catches ValidationError, so it
+ # escapes validation entirely and the endpoint 500s instead of rejecting the payload.
+ hog_flow, _ = self._create_hog_flow_with_action({})
+ hog_flow["actions"][1] = {"id": "bad_node", "name": "Tag person", "type": action_type, "config": {}}
+
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+
+ assert response.status_code == 400, response.json()
+
+ def test_non_string_action_type_error_does_not_echo_the_payload(self):
+ # The message interpolates the offending value, so a nested object would land in the response
+ # body and the logs behind it.
+ hog_flow, _ = self._create_hog_flow_with_action({})
+ secret = "dont-echo-me-9f3a"
+ hog_flow["actions"][1] = {"id": "bad_node", "name": "Tag person", "type": {"k": secret}, "config": {}}
+
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+
+ assert response.status_code == 400, response.json()
+ assert secret not in response.json()["detail"]
+
+ @parameterized.expand([(action_type,) for action_type in SUPPORTED_ACTION_TYPES])
+ def test_every_supported_action_type_is_accepted(self, action_type):
+ # The counterpart to the rejection above: tightening `type` must not lock out a type the
+ # worker does handle. Only the type field is under test, so per-type config errors are fine.
+ serializer = HogFlowActionSerializer(
+ data={"id": "a", "name": "a", "type": action_type, "config": {}},
+ context={"is_draft": True},
+ )
+ serializer.is_valid()
+
+ assert "type" not in serializer.errors
+
class TestHogFlowGlobalStats(ClickhouseTestMixin, APIBaseTest):
def setUp(self):
diff --git a/products/workflows/backend/models/hog_flow/hog_flow.py b/products/workflows/backend/models/hog_flow/hog_flow.py
index 2f4184cb7f23..ae98beaa5d90 100644
--- a/products/workflows/backend/models/hog_flow/hog_flow.py
+++ b/products/workflows/backend/models/hog_flow/hog_flow.py
@@ -18,6 +18,32 @@ if TYPE_CHECKING:
logger = structlog.get_logger(__name__)
+# Every action type the worker can execute. Must stay in sync with the `actionHandlers` registry in
+# nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts (and the schemas mirroring it in
+# nodejs/src/cdp/schema/hogflow.ts and products/workflows/frontend/Workflows/hogflows/steps/types.ts).
+# A type absent here has no handler, so the run dies on reaching it with "Action type 'x' not
+# supported" - and unless that step sets on_error: continue, everything downstream never happens.
+# Ordered longest-lived first so the generated API/MCP enum reads in a sensible order.
+SUPPORTED_ACTION_TYPES: Final[list[str]] = [
+ "trigger",
+ "function",
+ "function_email",
+ "function_sms",
+ "function_push",
+ "delay",
+ "wait_until_condition",
+ "wait_until_time_window",
+ "conditional_branch",
+ "random_cohort_branch",
+ "exit",
+]
+
+# The trigger's own kinds, which live in the workflow's `trigger` field rather than on an action.
+# Callers confuse the two (a stored workflow had an action of type "webhook", which is a trigger
+# kind), so the rejection message can say which mistake was made. Mirrors HogFlowTriggerSchema in
+# nodejs/src/cdp/schema/hogflow.ts.
+TRIGGER_TYPES: Final[frozenset[str]] = frozenset({"event", "schedule", "manual", "batch", "tracking_pixel", "webhook"})
+
# Billable action types that are subject to rate limiting and quota tracking
# These action types incur costs and are counted against customer quotas
BILLABLE_ACTION_TYPES: Final[set[str]] = {
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index b9a86dc7f783..fd39995c6974 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -383,6 +383,35 @@ 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, filters?}. 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. 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: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. 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 should sum to 100 (an unallocated remainder routes to the last cohort). 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}.
*/
@@ -431,11 +460,20 @@ export interface HogFlowActionApi {
updated_at?: number
/** Property filters gating this action. */
filters?: HogFunctionFiltersApi | null
- /**
- * trigger | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.
- * @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
/** Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. 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. 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: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. 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 should sum to 100 (an unallocated remainder routes to the last cohort). 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}. */
config: HogFlowActionApiConfig
/** Output variable for downstream actions: {key, result_path?, spread?, label?} or a list of those. */
diff --git a/products/workflows/frontend/generated/api.zod.ts b/products/workflows/frontend/generated/api.zod.ts
index fa7795b79168..2bb750977ba4 100644
--- a/products/workflows/frontend/generated/api.zod.ts
+++ b/products/workflows/frontend/generated/api.zod.ts
@@ -395,8 +395,6 @@ export const hogFlowsCreateBodyActionsItemNameMax = 400
export const hogFlowsCreateBodyActionsItemDescriptionDefault = ``
export const hogFlowsCreateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowsCreateBodyActionsItemTypeMax = 100
-
export const hogFlowsCreateBodyActionsItemConfigTwoConditionFiltersOneSourceDefault = `events`
export const hogFlowsCreateBodyActionsItemConfigTwoEventsItemFiltersOneSourceDefault = `events`
@@ -577,10 +575,24 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod
.optional()
.describe('Property filters gating this action.'),
type: zod
- .string()
- .max(hogFlowsCreateBodyActionsItemTypeMax)
+ .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 | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ '\* `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
.union([
@@ -727,8 +739,6 @@ export const hogFlowsUpdateBodyActionsItemNameMax = 400
export const hogFlowsUpdateBodyActionsItemDescriptionDefault = ``
export const hogFlowsUpdateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowsUpdateBodyActionsItemTypeMax = 100
-
export const hogFlowsUpdateBodyActionsItemConfigTwoConditionFiltersOneSourceDefault = `events`
export const hogFlowsUpdateBodyActionsItemConfigTwoEventsItemFiltersOneSourceDefault = `events`
@@ -909,10 +919,24 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zod
.optional()
.describe('Property filters gating this action.'),
type: zod
- .string()
- .max(hogFlowsUpdateBodyActionsItemTypeMax)
+ .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(
- 'trigger | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ '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
.union([
@@ -1059,8 +1083,6 @@ export const hogFlowsPartialUpdateBodyActionsItemNameMax = 400
export const hogFlowsPartialUpdateBodyActionsItemDescriptionDefault = ``
export const hogFlowsPartialUpdateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowsPartialUpdateBodyActionsItemTypeMax = 100
-
export const hogFlowsPartialUpdateBodyActionsItemConfigTwoConditionFiltersOneSourceDefault = `events`
export const hogFlowsPartialUpdateBodyActionsItemConfigTwoEventsItemFiltersOneSourceDefault = `events`
@@ -1246,10 +1268,24 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod
.optional()
.describe('Property filters gating this action.'),
type: zod
- .string()
- .max(hogFlowsPartialUpdateBodyActionsItemTypeMax)
+ .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 | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ '\* `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
.union([
@@ -1510,8 +1546,6 @@ export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemNameMax = 4
export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemDescriptionDefault = ``
export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemTypeMax = 100
-
export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemConfigTwoConditionFiltersOneSourceDefault = `events`
export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemConfigTwoEventsItemFiltersOneSourceDefault = `events`
export const hogFlowsInvocationsCreateBodyConfigurationOneSchedulesItemTimezoneMax = 64
@@ -1759,10 +1793,24 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({
.optional()
.describe('Property filters gating this action.'),
type: zod
- .string()
- .max(hogFlowsInvocationsCreateBodyConfigurationOneActionsItemTypeMax)
+ .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 | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ '\* `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
.union([
@@ -2134,8 +2182,6 @@ export const hogFlowsBulkDeleteCreateBodyActionsItemNameMax = 400
export const hogFlowsBulkDeleteCreateBodyActionsItemDescriptionDefault = ``
export const hogFlowsBulkDeleteCreateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowsBulkDeleteCreateBodyActionsItemTypeMax = 100
-
export const hogFlowsBulkDeleteCreateBodyActionsItemConfigTwoConditionFiltersOneSourceDefault = `events`
export const hogFlowsBulkDeleteCreateBodyActionsItemConfigTwoEventsItemFiltersOneSourceDefault = `events`
@@ -2321,10 +2367,24 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zod
.optional()
.describe('Property filters gating this action.'),
type: zod
- .string()
- .max(hogFlowsBulkDeleteCreateBodyActionsItemTypeMax)
+ .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(
- 'trigger | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ '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
.union([
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 5681cd0cb4f5..702eec10246d 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -33662,6 +33662,36 @@ export namespace Schemas {
Abort: 'abort',
} as const;
+ /**
+ * * `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 HogFlowActionTypeEnum = typeof HogFlowActionTypeEnum[keyof typeof HogFlowActionTypeEnum];
+
+
+ export const HogFlowActionTypeEnum = {
+ 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, filters?}. 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. 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: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. 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 should sum to 100 (an unallocated remainder routes to the last cohort). 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}.
*/
@@ -33708,11 +33738,20 @@ export namespace Schemas {
updated_at?: number;
/** Property filters gating this action. */
filters?: HogFunctionFilters | null;
- /**
- * trigger | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.
- * @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;
/** Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. 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. 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: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. 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 should sum to 100 (an unallocated remainder routes to the last cohort). 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}. */
config: HogFlowActionConfig;
/** Output variable for downstream actions: {key, result_path?, spread?, label?} or a list of those. */
diff --git a/services/mcp/src/generated/workflows/api.ts b/services/mcp/src/generated/workflows/api.ts
index 10cd1767f77e..fd74d1436098 100644
--- a/services/mcp/src/generated/workflows/api.ts
+++ b/services/mcp/src/generated/workflows/api.ts
@@ -51,8 +51,6 @@ export const hogFlowsCreateBodyActionsItemNameMax = 400
export const hogFlowsCreateBodyActionsItemDescriptionDefault = ``
export const hogFlowsCreateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowsCreateBodyActionsItemTypeMax = 100
-
export const hogFlowsCreateBodyActionsItemConfigTwoConditionFiltersOneSourceDefault = `events`
export const hogFlowsCreateBodyActionsItemConfigTwoEventsItemFiltersOneSourceDefault = `events`
@@ -233,10 +231,24 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod
.optional()
.describe('Property filters gating this action.'),
type: zod
- .string()
- .max(hogFlowsCreateBodyActionsItemTypeMax)
+ .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(
- 'trigger | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ '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
.union([
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json
index de5ed0369a55..3e04f7505c40 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json
@@ -298,8 +298,20 @@
"description": "Output variable for downstream actions: {key, result_path?, spread?, label?} or a list of those."
},
"type": {
- "description": "trigger | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.",
- "maxLength": 100,
+ "description": "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",
+ "enum": [
+ "trigger",
+ "function",
+ "function_email",
+ "function_sms",
+ "function_push",
+ "delay",
+ "wait_until_condition",
+ "wait_until_time_window",
+ "conditional_branch",
+ "random_cohort_branch",
+ "exit"
+ ],
"type": "string"
},
"updated_at": {