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 the history tab crashing on masked actions (#74617)

Daniel Marchuk1bad8d10480a
diff --git a/products/workflows/frontend/Workflows/misc/workflowActivityDescriber.test.tsx b/products/workflows/frontend/Workflows/misc/workflowActivityDescriber.test.tsx
new file mode 100644
index 000000000000..e23fd2ae56d2
--- /dev/null
+++ b/products/workflows/frontend/Workflows/misc/workflowActivityDescriber.test.tsx
@@ -0,0 +1,54 @@
+import { render } from '@testing-library/react'
+
+import { ActivityChange, ActivityLogItem } from 'lib/components/ActivityLog/humanizeActivity'
+
+import { ActivityScope } from '~/types'
+
+import { workflowActivityDescriber } from './workflowActivityDescriber'
+
+const getTextContent = (describer: { description: JSX.Element | string | null }): string => {
+ if (!describer.description || typeof describer.description === 'string') {
+ return (describer.description as string) || ''
+ }
+ const { container } = render(describer.description)
+ return container.textContent || ''
+}
+
+const workflowLogItem = (changes: ActivityChange[]): ActivityLogItem => ({
+ activity: 'updated',
+ created_at: '2026-07-29T10:00:00Z',
+ scope: 'HogFlow',
+ item_id: 'flow-uuid',
+ detail: { merge: null, trigger: null, changes, name: 'Welcome email' },
+})
+
+const change = (field: string, before: unknown, after: unknown): ActivityChange =>
+ ({ type: ActivityScope.HOG_FLOW, action: 'changed', field, before, after }) as ActivityChange
+
+describe('workflowActivityDescriber', () => {
+ // The backend masks `actions` because the graph can carry secret function inputs, so the log
+ // holds the string 'masked'. Mapping over that threw "itemsAfter.map is not a function" and
+ // took the whole History tab down with an error boundary.
+ it.each([
+ ['masked string', 'masked'],
+ ['object', {}],
+ ['number', 7],
+ ])('renders a plain line when an actions value is not an array (%s)', (_label, after) => {
+ const text = getTextContent(workflowActivityDescriber(workflowLogItem([change('actions', null, after)])))
+
+ expect(text).toContain('updated actions')
+ })
+
+ it('still diffs individual items when both sides really are arrays', () => {
+ const text = getTextContent(
+ workflowActivityDescriber(
+ workflowLogItem([
+ change('actions', [{ id: 'a1', name: 'Send email' }], [{ id: 'a2', name: 'Send push' }]),
+ ])
+ )
+ )
+
+ expect(text).toContain('added action Send push')
+ expect(text).toContain('deleted action Send email')
+ })
+})
diff --git a/products/workflows/frontend/Workflows/misc/workflowActivityDescriber.tsx b/products/workflows/frontend/Workflows/misc/workflowActivityDescriber.tsx
index 65ec41f1255b..abde592dbd8d 100644
--- a/products/workflows/frontend/Workflows/misc/workflowActivityDescriber.tsx
+++ b/products/workflows/frontend/Workflows/misc/workflowActivityDescriber.tsx
@@ -14,6 +14,16 @@ const nameOrLinkToWorkflow = (id?: string | null, name?: string | null): string
type ArrayChangeItem = { id?: string; key?: string; name?: string; label?: string }
+// Activity-log values are only diffable per item when they really are arrays. `actions` is masked
+// server-side (the graph can carry secret function inputs), so those entries hold the string
+// 'masked' rather than a list. Returns null for anything undiffable, so callers can fall back.
+function asItemArray(value: unknown): ArrayChangeItem[] | null {
+ if (value == null) {
+ return []
+ }
+ return Array.isArray(value) ? (value as ArrayChangeItem[]) : null
+}
+
function processArrayChanges<T extends ArrayChangeItem>(
itemsBefore: T[],
itemsAfter: T[],
@@ -144,8 +154,12 @@ export function workflowActivityDescriber(logItem: ActivityLogItem, asNotificati
break
}
case 'actions': {
- const actionsBefore = (change.before as any[]) || []
- const actionsAfter = (change.after as any[]) || []
+ const actionsBefore = asItemArray(change.before)
+ const actionsAfter = asItemArray(change.after)
+ if (!actionsBefore || !actionsAfter) {
+ changes.push(<>updated {change.field}</>)
+ break
+ }
changes.push(
...processArrayChanges(
actionsBefore,
@@ -158,8 +172,12 @@ export function workflowActivityDescriber(logItem: ActivityLogItem, asNotificati
break
}
case 'variables': {
- const variablesBefore = (change.before as any[]) || []
- const variablesAfter = (change.after as any[]) || []
+ const variablesBefore = asItemArray(change.before)
+ const variablesAfter = asItemArray(change.after)
+ if (!variablesBefore || !variablesAfter) {
+ changes.push(<>updated {change.field}</>)
+ break
+ }
changes.push(
...processArrayChanges(
variablesBefore,