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): stop step previews crashing on a config without inputs (#100259)

Georges-Antoine Assicc0a7e8c1579
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index ddcf1c96d60c..69302aafee9b 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6164,10 +6164,26 @@ snapshots:
hash: v1.k794b7964.5ca1cd71851625754d87c675688f56c0feb039ade940912f8df2ddd171d89d83.5SQmAn1fsl5RQ572BttZHT0wNAtJeZRNP0OqajxrUMc
products-workflows-template-card--ai--light:
hash: v1.k794b7964.5a31f5a57fe751ed5a9ec04bca6f2d5f62e2fbd86179cee3454db11924f21be1.GEdQ_SUwmnx3J9sqhog7T_uNJYnC5ph5eiKOwoYui-A
+ products-workflows-template-card--basic--dark:
+ hash: v1.k794b7964.5e92df62c57af26cdce62c752d1520bc51346a86f584de4915711155f46c30ef.9yCP2MeM_W_Gw2LyPZV1mkP_IvvWpHDA1e-sna1BFSw
+ products-workflows-template-card--basic--light:
+ hash: v1.k794b7964.fcad6a84112c48e0c1178e59477421d96950329743fce424d13a9798a207bd75.WQYkIoH-tZPH9NEwyfbOyEm79f7bcqGlX9DUaxNGcgE
products-workflows-template-card--blank--dark:
hash: v1.k794b7964.23ca3e9c4eb925a659ce4553dda6c27955f48bafba4fc1355c3d7c0cefcec862.M-USb6QCbLNLEHpio3NNncnc1FRh-JSo7oV0XEosD1Y
products-workflows-template-card--blank--light:
hash: v1.k794b7964.10249e46871b8b2f8382d2af9c62214098bf6a1a8f4baed3f2cdea8a43d45914.pDn78avyYvuB8i7MQotDOvokbWJUDneghYCfxxv7M0Q
+ products-workflows-template-card--longest-description--dark:
+ hash: v1.k794b7964.11dc07a26fd819ad4c9c5b41131c626fe54262f12a0fe8b033fdbbb694bc9988.WdUl8hdamKaJUeScrYS9KGkYYv1r0sUApsJRzZBsZo4
+ products-workflows-template-card--longest-description--light:
+ hash: v1.k794b7964.8ca8ae54cf847387bcab9cdea9a3f313158da6f3cf091b551e42cf21dd13e2df._bJpmDR8Vk8OSIsYIzzDA0Ip_q9y1c5hwwcC06giQWA
+ products-workflows-template-card--narrow--dark:
+ hash: v1.k794b7964.02cd68ad28118eef7360a8d93cdb71a3aa80b3bf23d71788bb4c1cd02b647a98.YodJ5IXVT3EoRbzZ0Zw52XiuRcb0hUV8BJbxi3gu3YY
+ products-workflows-template-card--narrow--light:
+ hash: v1.k794b7964.f14ce1bd1533072e19f0dd4136807a43502ba958d1c01970552955bb0bd16505.BRimZEFm-Oh0wDZSnWuwP_gCiXgS6mV9DhkaUopQxFI
+ products-workflows-template-card--picker--dark:
+ hash: v1.k794b7964.ded75abe4e8eb09bccf9b970188d13b022bf0c43636e887273791b72a4636ee2.R28mwGSEfFH1ZxrFl4cRA-zpg5RprlDTRSu96cg-v20
+ products-workflows-template-card--picker--light:
+ hash: v1.k794b7964.59e165d7ede2cc4e3138b95c64a7329134a16e722ff2fe224f8bf700e81d544c.SRWbL89CbOMgwObgHB8qGt_63Lh4SB0-2of7YS3PlQw
queries-webvitals--web-vitals--dark:
hash: v1.k794b7964.2ae778a0c5fdba3c69dfcbd3e9589c3c3d9cc2f0fef2eefd304c565be7e9a7c9.hH71byl33sIAdRCgaPk1lDOev0qooW1xhv0AL_yrIvg
queries-webvitals--web-vitals--light:
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/HogFlowSteps.test.ts b/products/workflows/frontend/Workflows/hogflows/steps/HogFlowSteps.test.ts
index 9720aeee021c..67dc52f4e7cb 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/HogFlowSteps.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/steps/HogFlowSteps.test.ts
@@ -48,6 +48,17 @@ describe('HogFlow step previews', () => {
expect(previewLabels(workflowAction)).toEqual(expected)
})
+ it.each([
+ [action('conditional_branch', {}), ['0 conditions']],
+ [action('random_cohort_branch', {}), ['0 cohorts']],
+ [action('function', { template_id: 'template-webhook' }), ['POST']],
+ [action('function_email', {}), ['Email']],
+ [action('function_sms', {}), ['SMS']],
+ [action('function_push', {}), ['Push notification']],
+ ])('falls back to a generic label when the config carries no inputs', (workflowAction, expected) => {
+ expect(previewLabels(workflowAction)).toEqual(expected)
+ })
+
it('adds the number of action conditions', () => {
const workflowAction = {
...action('function', {
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/HogFlowSteps.tsx b/products/workflows/frontend/Workflows/hogflows/steps/HogFlowSteps.tsx
index 16d6a666a97d..599a7b4589fb 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/HogFlowSteps.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/HogFlowSteps.tsx
@@ -111,7 +111,7 @@ function getFunctionPreviews(
): HogFlowStepPreview[] {
const destination = getNotificationDescription({ inputs: action.config.inputs })
if (action.config.template_id === 'template-webhook') {
- const method = String(action.config.inputs.method?.value || 'POST').toUpperCase()
+ const method = String(action.config.inputs?.method?.value || 'POST').toUpperCase()
return [{ label: destination ? `${method} ${destination}` : method }]
}
@@ -126,11 +126,10 @@ const HogFlowStepConfigs: Partial<{
type: 'conditional_branch',
icon: () => <IconDecisionTree />,
color: (_, isDarkModeOn) => (isDarkModeOn ? '#35C46F' : '#005841'),
- getPreviews: (action) => [
- {
- label: `${action.config.conditions.length} ${action.config.conditions.length === 1 ? 'condition' : 'conditions'}`,
- },
- ],
+ getPreviews: (action) => {
+ const count = action.config.conditions?.length ?? 0
+ return [{ label: `${count} ${count === 1 ? 'condition' : 'conditions'}` }]
+ },
renderConfiguration: (node) => <StepConditionalBranchConfiguration key={node.id} node={node} />,
},
delay: {
@@ -152,11 +151,10 @@ const HogFlowStepConfigs: Partial<{
type: 'random_cohort_branch',
icon: () => <IconPercentage />,
color: (_, isDarkModeOn) => (isDarkModeOn ? '#D6247B' : '#9a004d'),
- getPreviews: (action) => [
- {
- label: `${action.config.cohorts.length} ${action.config.cohorts.length === 1 ? 'cohort' : 'cohorts'}`,
- },
- ],
+ getPreviews: (action) => {
+ const count = action.config.cohorts?.length ?? 0
+ return [{ label: `${count} ${count === 1 ? 'cohort' : 'cohorts'}` }]
+ },
renderConfiguration: (node) => <StepRandomCohortBranchConfiguration key={node.id} node={node} />,
},
trigger: {
@@ -198,7 +196,7 @@ const HogFlowStepConfigs: Partial<{
color: (_, isDarkModeOn) => (isDarkModeOn ? '#2F80FA' : '#2F80FA'),
getPreviews: (action) => [
{
- label: action.config.inputs.email?.value?.to?.email
+ label: action.config.inputs?.email?.value?.to?.email
? `To ${action.config.inputs.email.value.to.email}`
: 'Email',
},
@@ -210,7 +208,11 @@ const HogFlowStepConfigs: Partial<{
icon: () => <IconTwilio />,
color: () => '#f22f46',
getPreviews: (action) => [
- { label: action.config.inputs.phoneNumber?.value ? `To ${action.config.inputs.phoneNumber.value}` : 'SMS' },
+ {
+ label: action.config.inputs?.phoneNumber?.value
+ ? `To ${action.config.inputs.phoneNumber.value}`
+ : 'SMS',
+ },
],
renderConfiguration: (node) => <StepFunctionConfiguration key={node.id} node={node} />,
},
@@ -220,7 +222,7 @@ const HogFlowStepConfigs: Partial<{
color: (_, isDarkModeOn) => (isDarkModeOn ? '#F8BE2A' : '#F44D01'),
getPreviews: (action) => [
{
- label: action.config.inputs.title?.value
+ label: action.config.inputs?.title?.value
? String(action.config.inputs.title.value)
: 'Push notification',
},
diff --git a/products/workflows/frontend/Workflows/templates/WorkflowTemplateCard.stories.tsx b/products/workflows/frontend/Workflows/templates/WorkflowTemplateCard.stories.tsx
index 7d2b87be40cc..17e463fffd64 100644
--- a/products/workflows/frontend/Workflows/templates/WorkflowTemplateCard.stories.tsx
+++ b/products/workflows/frontend/Workflows/templates/WorkflowTemplateCard.stories.tsx
@@ -18,28 +18,77 @@ export default meta
type StepSpec = HogFlowAction['type'] | [HogFlowAction['type'], string]
+type TemplateTrigger = 'event' | 'schedule' | 'internal-event'
+
+function triggerConfig(type: TemplateTrigger): Record<string, unknown> {
+ switch (type) {
+ case 'event':
+ return { type, filters: {} }
+ case 'internal-event':
+ return {
+ type,
+ filters: { source: 'internal-events', events: [{ id: '$error_tracking_issue_created' }] },
+ }
+ case 'schedule':
+ return { type }
+ }
+}
+
+function stepConfig(type: HogFlowAction['type'], templateId?: string): Record<string, unknown> {
+ switch (type) {
+ case 'delay':
+ return { delay_duration: '3d' }
+ case 'conditional_branch':
+ return { conditions: [{ filters: {} }] }
+ case 'function_email':
+ return {
+ template_id: templateId,
+ inputs: { email: { value: { to: { email: '[email protected]' } } } },
+ }
+ case 'function':
+ return templateId === 'template-webhook'
+ ? { template_id: templateId, inputs: { url: { value: 'https://hooks.example.com/workflow' } } }
+ : { template_id: templateId, inputs: { channel: { value: '#support' } } }
+ default:
+ return {}
+ }
+}
+
function template(
name: string,
description: string,
- trigger: string,
+ trigger: TemplateTrigger,
steps: StepSpec[],
tags: string[] = []
): HogFlowTemplate {
const actions = [
- { id: 'trigger', type: 'trigger', name: 'Trigger', config: { type: trigger, filters: {} } },
+ { id: 'trigger', type: 'trigger', name: 'Trigger', config: triggerConfig(trigger) },
...steps.map((step, index) => {
const [type, templateId] = Array.isArray(step) ? step : [step, undefined]
- return { id: `${type}_${index}`, type, name: type, config: templateId ? { template_id: templateId } : {} }
+ return { id: `${type}_${index}`, type, name: type, config: stepConfig(type, templateId) }
}),
{ id: 'exit', type: 'exit', name: 'Exit', config: {} },
- ]
+ ] as HogFlowAction[]
// The shipped templates chain their steps with `continue` edges, and the card reads that chain
const edges = actions.slice(0, -1).map((action, index) => ({
from: action.id,
to: actions[index + 1].id,
- type: 'continue',
+ type: 'continue' as const,
}))
- return { id: name, name, description, actions, edges, tags, scope: 'global' } as unknown as HogFlowTemplate
+ return {
+ id: name,
+ team_id: 1,
+ version: 1,
+ name,
+ description,
+ exit_condition: 'exit_only_at_end',
+ actions,
+ edges,
+ tags,
+ scope: 'global',
+ created_at: '2026-01-01T00:00:00Z',
+ updated_at: '2026-01-01T00:00:00Z',
+ }
}
// Copied from the templates that ship in products/workflows/backend/templates, so the card is