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.

feat(workflows): skip runs forward past deleted steps (#71844)

Harley Alexander5ed4d97131fd
diff --git a/nodejs/src/cdp/schema/hogflow.ts b/nodejs/src/cdp/schema/hogflow.ts
index f5c0068ce36c..8dbda3a14d46 100644
--- a/nodejs/src/cdp/schema/hogflow.ts
+++ b/nodejs/src/cdp/schema/hogflow.ts
@@ -277,6 +277,9 @@ export const HogFlowSchema = z.object({
edges: z.array(HogFlowEdgeSchema),
variables: z.array(CyclotronJobInputSchemaTypeSchema).optional().nullable(),
billable_action_types: z.array(z.string()).optional().nullable(),
+ // Skip-forward map for deleted steps ({deleted_action_id: surviving_action_id}), maintained by
+ // the API on live graph edits. Values always reference actions present in this flow's `actions`.
+ action_redirects: z.record(z.string(), z.string()).optional().nullable(),
// Selected by the worker (HOG_FLOW_FIELDS); pg returns timestamptz as a Date, fixtures use
// epoch millis. Used to distinguish live edits from malformed-from-birth graphs.
updated_at: z.union([z.number(), z.string(), z.date()]).optional(),
diff --git a/nodejs/src/cdp/services/hogflows/__snapshots__/hogflow-manager.service.test.ts.snap b/nodejs/src/cdp/services/hogflows/__snapshots__/hogflow-manager.service.test.ts.snap
index 9f0bf29f3890..b28063029836 100644
--- a/nodejs/src/cdp/services/hogflows/__snapshots__/hogflow-manager.service.test.ts.snap
+++ b/nodejs/src/cdp/services/hogflows/__snapshots__/hogflow-manager.service.test.ts.snap
@@ -4,6 +4,7 @@ exports[`HogFlowManager returns the hog flow 1`] = `
[
{
"abort_action": null,
+ "action_redirects": null,
"actions": [
{
"config": {
@@ -70,6 +71,7 @@ exports[`HogFlowManager returns the hog flow 1`] = `
},
{
"abort_action": null,
+ "action_redirects": null,
"actions": [
{
"config": {
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
index 4715b758d925..43c471ed7840 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
@@ -676,6 +676,174 @@ describe('Hogflow Executor', () => {
expect(result.metrics.map((m) => m.metric_name)).toContain('failed')
expect(result.metrics.map((m) => m.metric_name)).not.toContain('exited_workflow_changed')
})
+
+ describe('skip-forward for deleted steps (action_redirects)', () => {
+ const parkOnDeleted = (
+ hogFlow: HogFlow,
+ actionId = 'delay'
+ ): ReturnType<typeof createExampleHogFlowInvocation> => {
+ const invocation = createExampleHogFlowInvocation(hogFlow)
+ invocation.state.currentAction = {
+ id: actionId,
+ startedAtTimestamp: DateTime.now().minus({ hours: 3 }).toMillis(),
+ }
+ hogFlow.actions = hogFlow.actions.filter((action) => action.id !== actionId)
+ hogFlow.updated_at = DateTime.now().toMillis()
+ return invocation
+ }
+
+ // A run can be parked on any async step type. The redirect never inspects the
+ // deleted step - it was removed before the run executed it - so every park type
+ // must take the identical path: same metric, same log, same landing spot.
+ it.each([
+ ['delay', { type: 'delay', config: { delay_duration: '2h' } }],
+ [
+ 'wait_until_condition',
+ {
+ type: 'wait_until_condition',
+ config: {
+ condition: { filters: HOG_FILTERS_EXAMPLES.elements_text_filter.filters },
+ max_wait_duration: '10m',
+ },
+ },
+ ],
+ [
+ 'wait_until_time_window',
+ {
+ type: 'wait_until_time_window',
+ config: { time: ['10:00', '11:00'], day: 'any', timezone: 'UTC' },
+ },
+ ],
+ ] as const)(
+ 'continues at the surviving successor instead of exiting (parked on %s)',
+ async (_parkType, parkedAction) => {
+ const hogFlow = createHogFlow({
+ actions: { parked: parkedAction as any },
+ edges: [
+ { from: 'trigger', to: 'parked', type: 'continue' },
+ { from: 'parked', to: 'exit', type: 'continue' },
+ ],
+ })
+ const invocation = parkOnDeleted(hogFlow, 'parked')
+ hogFlow.action_redirects = { parked: 'exit' }
+
+ const result = await executor.execute(invocation)
+
+ expect(result.finished).toBe(true)
+ expect(result.error).toBeUndefined()
+ const redirectMetric = result.metrics.find(
+ (m) => m.metric_name === 'redirected_workflow_changed'
+ )
+ expect(redirectMetric).toMatchObject({ metric_kind: 'other', instance_id: 'parked' })
+ expect(result.metrics.map((m) => m.metric_name)).not.toContain('exited_workflow_changed')
+ expect(result.metrics.map((m) => m.metric_name)).not.toContain('failed')
+ expect(result.logs.map((l) => l.message).join('\n')).toContain('continuing at [Action:exit]')
+ }
+ )
+
+ it('enters the redirect target fresh, so a delay there parks from redirect time', async () => {
+ // The run spent 3h on the deleted step; the 2h delay it redirects into must still
+ // park for its full 2h rather than treating the old step entry time as its own
+ const hogFlow = createHogFlow({
+ actions: { delay_2: { type: 'delay', config: { delay_duration: '2h' } } },
+ edges: [
+ { from: 'trigger', to: 'delay', type: 'continue' },
+ { from: 'delay', to: 'delay_2', type: 'continue' },
+ { from: 'delay_2', to: 'exit', type: 'continue' },
+ ],
+ })
+ const invocation = parkOnDeleted(hogFlow)
+ hogFlow.action_redirects = { delay: 'delay_2' }
+
+ const result = await executor.execute(invocation)
+
+ expect(result.finished).toBe(false)
+ expect(result.invocation.queueScheduledAt?.toMillis()).toEqual(
+ DateTime.now().plus({ hours: 2 }).toMillis()
+ )
+ })
+
+ it.each([
+ [
+ 'the dead position has no map entry',
+ (hogFlow: HogFlow) => {
+ hogFlow.actions = hogFlow.actions.filter((action) => action.id !== 'delay')
+ },
+ ],
+ [
+ 'the surviving position lost its edge (map keys are deleted steps only)',
+ (hogFlow: HogFlow) => {
+ hogFlow.edges = hogFlow.edges.filter((edge) => edge.from !== 'delay')
+ },
+ ],
+ ])('still exits gracefully when %s', async (_desc, mutateFlow) => {
+ const hogFlow = buildFlow()
+ const invocation = createExampleHogFlowInvocation(hogFlow)
+ invocation.state.currentAction = {
+ id: 'delay',
+ startedAtTimestamp: DateTime.now().minus({ hours: 3 }).toMillis(),
+ }
+ mutateFlow(hogFlow)
+ hogFlow.updated_at = DateTime.now().toMillis()
+ // An entry for an unrelated deleted step must not capture this run
+ hogFlow.action_redirects = { some_other_step: 'exit' }
+
+ const result = await executor.execute(invocation)
+
+ expect(result.finished).toBe(true)
+ expect(result.error).toBeUndefined()
+ expect(result.metrics.map((m) => m.metric_name)).toContain('exited_workflow_changed')
+ expect(result.metrics.map((m) => m.metric_name)).not.toContain('redirected_workflow_changed')
+ })
+
+ it('never redirects a graph that was malformed all along, even with a map entry', async () => {
+ const hogFlow = buildFlow()
+ const invocation = createExampleHogFlowInvocation(hogFlow)
+ invocation.state.currentAction = {
+ id: 'delay',
+ startedAtTimestamp: DateTime.now().minus({ hours: 3 }).toMillis(),
+ }
+ hogFlow.actions = hogFlow.actions.filter((action) => action.id !== 'delay')
+ hogFlow.action_redirects = { delay: 'exit' }
+ // No edit since the run arrived: the timestamp guard must run before any redirect
+ hogFlow.updated_at = DateTime.now().minus({ hours: 4 }).toMillis()
+
+ const result = await executor.execute(invocation)
+
+ expect(result.finished).toBe(true)
+ expect(result.error).toBe('Action delay not found')
+ // Deleting the current action itself throws in ensureCurrentAction, before the
+ // per-action failure metric is emitted - so the loud failure surfaces via
+ // result.error rather than a 'failed' metric (unlike a deleted *edge*, which
+ // throws inside the action handler where the metric is tracked).
+ expect(result.metrics.map((m) => m.metric_name)).not.toContain('redirected_workflow_changed')
+ })
+
+ it('fails the run (no loop) when the redirect target itself dead-ends', async () => {
+ // The target enters with a fresh step timestamp, so its own structural miss no
+ // longer classifies as a live edit - it must surface as a plain failure. Uses a
+ // trigger target so the dead end throws synchronously on entry (a delay would
+ // park first and only fail on the next wake, which one execute() can't observe).
+ const hogFlow = createHogFlow({
+ actions: { hop: { type: 'trigger', config: { type: 'schedule' } } },
+ edges: [
+ { from: 'trigger', to: 'delay', type: 'continue' },
+ { from: 'delay', to: 'hop', type: 'continue' },
+ { from: 'hop', to: 'exit', type: 'continue' },
+ ],
+ })
+ const invocation = parkOnDeleted(hogFlow)
+ hogFlow.edges = hogFlow.edges.filter((edge) => edge.from !== 'hop')
+ hogFlow.action_redirects = { delay: 'hop' }
+
+ const result = await executor.execute(invocation)
+
+ expect(result.finished).toBe(true)
+ expect(result.error).toBe('No next action found for action hop')
+ expect(result.metrics.map((m) => m.metric_name)).toContain('redirected_workflow_changed')
+ expect(result.metrics.map((m) => m.metric_name)).toContain('failed')
+ })
+ })
})
// The follow-live contract: the worker re-reads live config on every wake, so edits made
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
index 51744807ff3d..82521206e4bd 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
@@ -1,5 +1,6 @@
import { get } from 'lodash'
import { DateTime } from 'luxon'
+import { Counter } from 'prom-client'
import { HogFlow, HogFlowAction } from '~/cdp/schema/hogflow'
import { logger } from '~/common/utils/logger'
@@ -44,6 +45,19 @@ import {
export const MAX_ACTION_STEPS_HARD_LIMIT = 1000
+// Deliberately unlabelled: fleet-wide volume is the signal; which flow/step redirected where is in
+// the run's log line, where unbounded cardinality belongs.
+const counterRedirectApplied = new Counter({
+ name: 'cdp_hogflow_redirect_applied',
+ help: 'A run parked on a deleted step was redirected to its surviving successor',
+})
+// The API guarantees redirect targets exist in the same flow row; nonzero means that invariant broke
+// (the affected runs still exit gracefully rather than follow the bad entry).
+const counterRedirectTargetMissing = new Counter({
+ name: 'cdp_hogflow_redirect_target_missing',
+ help: 'A redirect map entry pointed at an action missing from the live graph',
+})
+
export function createHogFlowInvocation(
globals: HogFunctionInvocationGlobals,
hogFlow: HogFlow,
@@ -514,10 +528,14 @@ export class HogFlowExecutorService {
}
} catch (err) {
// The workflow was edited underneath this run and its current step (or that step's next
- // edge) no longer exists. That's a user action, not a defect: finish the run as a
- // deliberate exit - no result.error, so it doesn't count towards the workflow's failure
- // rate - with its own metric so exits are attributable per workflow.
+ // edge) no longer exists. That's a user action, not a defect: skip the run forward to the
+ // deleted step's surviving successor when the edit recorded one, otherwise finish the run
+ // as a deliberate exit - no result.error, so it doesn't count towards the workflow's
+ // failure rate - with its own metric so exits are attributable per workflow.
if (this.isLiveEditWorkflowChange(err, invocation)) {
+ if (this.maybeRedirectDeletedAction(result, invocation)) {
+ return result
+ }
result.finished = true
this.log(
result,
@@ -554,6 +572,60 @@ export class HogFlowExecutorService {
return result
}
+ // Skip-forward for deleted steps: when a live edit deleted the run's current action, the API
+ // recorded its next surviving successor in the flow's action_redirects map. Move the run there
+ // with a fresh step entry (so a delay/wait at the target parks from redirect time) and let the
+ // execute() loop enter it; the caller falls back to the graceful exit when there's no entry (a
+ // true dead end). Only ever reached behind isLiveEditWorkflowChange: the run's position is dead,
+ // so entries keyed by a *surviving* action id can't match, and after the redirect the fresh
+ // startedAtTimestamp means a second structural miss classifies as a plain failure, not a loop.
+ private maybeRedirectDeletedAction(
+ result: CyclotronJobInvocationResult<CyclotronJobInvocationHogFlow>,
+ invocation: CyclotronJobInvocationHogFlow
+ ): boolean {
+ const deletedActionId = invocation.state.currentAction?.id
+ const redirectId = deletedActionId ? invocation.hogFlow.action_redirects?.[deletedActionId] : undefined
+ if (!deletedActionId || !redirectId) {
+ return false
+ }
+
+ // The API keeps every map value present in the same row's actions, so a miss here means a
+ // compute bug or torn data - don't trust the map, let the run exit gracefully instead.
+ const target = invocation.hogFlow.actions.find((action) => action.id === redirectId)
+ if (!target) {
+ counterRedirectTargetMissing.inc()
+ logger.warn('[HogFlowExecutor] Redirect target missing from live graph', {
+ hogFlowId: invocation.hogFlow.id,
+ deletedActionId,
+ redirectId,
+ })
+ return false
+ }
+
+ result.finished = false
+ result.invocation.state.actionStepCount++
+ result.invocation.state.currentAction = {
+ id: target.id,
+ startedAtTimestamp: DateTime.now().toMillis(),
+ }
+ this.log(
+ result,
+ 'info',
+ `Workflow was edited and this run's current step was removed - continuing at ${actionIdForLogging(target)}`
+ )
+ result.metrics.push({
+ team_id: invocation.hogFlow.team_id,
+ app_source_id: invocation.parentRunId ?? invocation.hogFlow.id,
+ instance_id: deletedActionId,
+ metric_kind: 'other',
+ metric_name: 'redirected_workflow_changed',
+ count: 1,
+ })
+ counterRedirectApplied.inc()
+
+ return true
+ }
+
// A structural lookup miss only counts as a live edit when the flow was actually updated after
// the run arrived at its current step. Otherwise the graph was malformed from the start (a bad
// save, a lenient draft in a test run) and hiding it as a deliberate exit would bury the defect.
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-manager.service.ts b/nodejs/src/cdp/services/hogflows/hogflow-manager.service.ts
index b6fd067df976..9074081ceeeb 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-manager.service.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-manager.service.ts
@@ -24,6 +24,7 @@ const HOG_FLOW_FIELDS = [
'abort_action',
'billable_action_types',
'variables',
+ 'action_redirects',
]
export type HogFlowTeamInfo = Pick<HogFlow, 'id' | 'team_id' | 'version'>
diff --git a/nodejs/src/cdp/types.ts b/nodejs/src/cdp/types.ts
index 4d546dbb452e..f531989bbec5 100644
--- a/nodejs/src/cdp/types.ts
+++ b/nodejs/src/cdp/types.ts
@@ -247,6 +247,7 @@ export type MinimalAppMetric = {
| 'quota_limited'
| 'conversion'
| 'exited_workflow_changed'
+ | 'redirected_workflow_changed'
count: number
}
diff --git a/posthog/models/activity_logging/activity_log.py b/posthog/models/activity_logging/activity_log.py
index 463213ffe8db..906e20dd2e6c 100644
--- a/posthog/models/activity_logging/activity_log.py
+++ b/posthog/models/activity_logging/activity_log.py
@@ -428,6 +428,11 @@ activity_visibility_restrictions: list[dict[str, Any]] = [
]
field_exclusions: dict[AuditableScope, list[str]] = {
+ "HogFlow": [
+ # System-maintained skip-forward map for deleted steps, refreshed as a side effect of graph
+ # writes — bookkeeping, not a user edit, so keep it out of change diffs.
+ "action_redirects",
+ ],
"Metric": [
# Derived/throttled fields, not user-meaningful change diffs.
"last_run_at",
diff --git a/products/workflows/backend/api/action_redirects.py b/products/workflows/backend/api/action_redirects.py
new file mode 100644
index 000000000000..019f6d3e2daf
--- /dev/null
+++ b/products/workflows/backend/api/action_redirects.py
@@ -0,0 +1,91 @@
+# Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}, persisted on
+# HogFlow.action_redirects. When a live graph edit deletes a step that in-flight runs are parked on,
+# the worker resolves the run's dead position with one dict lookup and continues at the surviving
+# successor instead of exiting the run. Pure functions here — no DB — so they're cheap to unit-test
+# exhaustively, like graph_operations.
+#
+# The walk follows only `continue` edges: that's the graph's declared unconditional default (the
+# no-match fall-through of conditional_branch, the timeout path of wait_until_condition). Branch
+# edges encode a qualification decided by the deleted node's config, which no longer exists — routing
+# a run down one would put it on a targeted path it never qualified for. This deliberately diverges
+# from graph_operations.remove_action's edit-time reroute (first outgoer of any edge type): that
+# patches the stored graph's shape; this decides where a *person* goes.
+
+# The map self-prunes on re-adds, but entries whose targets stay live persist — so an editor churning
+# uniquely-named steps could grow it without bound. Cap it well above any real flow's step count;
+# on overflow keep the newest entries (dict order: prior-edit entries first, this edit's last), and
+# runs parked on a dropped one take the pre-existing graceful exit.
+MAX_ACTION_REDIRECTS = 512
+
+
+def compute_action_redirects(
+ old_actions: list[dict],
+ old_edges: list[dict],
+ new_actions: list[dict],
+ existing: dict[str, str] | None,
+) -> dict[str, str] | None:
+ """Diff the old graph against the new one and return the merged redirect map, or None when empty.
+
+ For each action id deleted by this edit, walk the old graph's continue edges (skipping through
+ other deleted nodes) to the first id that survives in the new graph. Dead ends — no continue
+ edge, a cycle, or everything downstream deleted too — are omitted, so the worker's graceful-exit
+ fallback keeps handling them and `exited_workflow_changed` keeps measuring true dead ends.
+
+ The result is normalized against the new graph, folding in `existing` (the map from prior
+ edits): entries whose key was re-added are pruned, entries whose target was deleted by this edit
+ are rewritten through this edit's redirects (or dropped when the target has no survivor). The
+ invariant this maintains: every value references an action present in the same row's `actions`,
+ so a run any number of edits behind resolves in exactly one lookup.
+ """
+ old_ids = {action["id"] for action in old_actions if action.get("id")}
+ new_ids = {action["id"] for action in new_actions if action.get("id")}
+
+ # First continue edge per node, matching the worker's findNextAction (first match wins).
+ continue_targets: dict[str, str] = {}
+ for edge in old_edges:
+ source, target = edge.get("from"), edge.get("to")
+ if edge.get("type") == "continue" and source and target and source not in continue_targets:
+ continue_targets[source] = target
+
+ # Each old node's surviving successor is resolved at most once and shared across walks —
+ # deleting a long chain would otherwise re-walk the same tail once per deleted node (O(n²)).
+ resolved: dict[str, str | None] = {}
+ fresh: dict[str, str] = {}
+ for deleted_id in old_ids - new_ids:
+ path = [deleted_id]
+ on_path = {deleted_id}
+ survivor: str | None = None
+ cursor = continue_targets.get(deleted_id)
+ while cursor is not None:
+ if cursor in new_ids:
+ survivor = cursor
+ break
+ if cursor in resolved:
+ survivor = resolved[cursor]
+ break
+ if cursor in on_path: # cycle of deleted nodes: dead end
+ break
+ path.append(cursor)
+ on_path.add(cursor)
+ cursor = continue_targets.get(cursor)
+ for node in path:
+ resolved[node] = survivor
+ if survivor is not None:
+ fresh[deleted_id] = survivor
+
+ merged: dict[str, str] = {}
+ for key, target in (existing or {}).items():
+ if key in new_ids:
+ continue # Step re-added: runs standing on it execute it normally again.
+ if target in new_ids:
+ merged[key] = target
+ elif target in fresh:
+ merged[key] = fresh[target]
+ # else: target deleted with no survivor — drop the entry; those runs exit gracefully.
+ # Fresh entries win over stale ones: they're computed from the graph as it is right now.
+ merged.update(fresh)
+
+ if len(merged) > MAX_ACTION_REDIRECTS:
+ merged = dict(list(merged.items())[-MAX_ACTION_REDIRECTS:])
+
+ return merged or None
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.py
index 754d7a2fdf66..578e08cb4bd2 100644
--- a/products/workflows/backend/api/hog_flow.py
+++ b/products/workflows/backend/api/hog_flow.py
@@ -72,6 +72,7 @@ from products.feature_flags.backend.user_blast_radius import (
get_user_blast_radius_persons,
)
from products.notifications.backend.facade.api import publish_resource_edited
+from products.workflows.backend.api.action_redirects import compute_action_redirects
from products.workflows.backend.api.graph_operations import apply_graph_operations
from products.workflows.backend.api.graph_validation import validate_graph
from products.workflows.backend.api.hog_flow_batch_job import HogFlowBatchJobSerializer
@@ -364,7 +365,9 @@ class HogFlowActionConfigField(serializers.JSONField):
class HogFlowActionSerializer(serializers.Serializer):
- id = serializers.CharField(help_text="Unique node ID within the workflow.")
+ # max_length bounds every downstream copy of the id (edges, action_redirects, worker cache);
+ # real ids are short generated slugs, so 200 is generous.
+ id = serializers.CharField(max_length=200, help_text="Unique node ID within the workflow.")
name = serializers.CharField(max_length=400, help_text="Display name.")
description = serializers.CharField(allow_blank=True, default="", help_text="Optional description.")
on_error = serializers.ChoiceField(
@@ -968,6 +971,16 @@ class HogFlowSerializer(HogFlowMinimalSerializer):
"mismatch returns 409."
),
)
+ action_redirects = serializers.DictField(
+ child=serializers.CharField(),
+ read_only=True,
+ allow_null=True,
+ help_text=(
+ "Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained "
+ "automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step "
+ "continue at its surviving successor instead of exiting. Null when no live deletions have occurred."
+ ),
+ )
def to_internal_value(self, data):
status = data.get("status")
@@ -1013,6 +1026,7 @@ class HogFlowSerializer(HogFlowMinimalSerializer):
"user_access_level",
"draft",
"draft_updated_at",
+ "action_redirects",
]
read_only_fields = [
"id",
@@ -1027,6 +1041,7 @@ class HogFlowSerializer(HogFlowMinimalSerializer):
"user_access_level",
"draft", # Written by draft routing (see perform_update / graph), never directly
"draft_updated_at",
+ "action_redirects", # Computed from graph diffs at save time (see _refresh_action_redirects)
]
def validate(self, data):
@@ -1623,6 +1638,10 @@ class HogFlowViewSet(
serializer.validated_data.update(remaining)
serializer.save()
else:
+ if before_update is not None:
+ self._refresh_action_redirects(
+ serializer.instance, before_update, serializer.validated_data.get("actions")
+ )
serializer.save()
if not route_to_draft:
@@ -1656,6 +1675,20 @@ class HogFlowViewSet(
except Exception as e:
logger.warning("Failed to capture hog_flow_activated event", error=str(e))
+ def _refresh_action_redirects(self, target: HogFlow, old: HogFlow, new_actions: Optional[list]) -> None:
+ # Skip-forward for deleted steps: refresh the redirect map whenever a live graph write is about
+ # to land, while both the old graph (`old`, the locked pre-write row) and the new actions are in
+ # hand. Must run before serializer.save() so the map persists in the same write, transaction,
+ # and worker reload as the graph it describes. Flag-gated with the rest of the revisions cycle.
+ # No status gate: disabling a flow doesn't purge its parked runs (the worker only cancels them
+ # if they wake while the flow is still disabled), so a step deleted during a disable/re-enable
+ # window needs its redirect recorded just like one deleted live.
+ if new_actions is None or not use_workflows_revisions(self.team):
+ return
+ target.action_redirects = compute_action_redirects(
+ old.actions or [], old.edges or [], new_actions, old.action_redirects
+ )
+
def _write_draft(self, instance: HogFlow, locked: HogFlow, validated_data: dict) -> None:
# The draft is always a full content snapshot (live config as the base, staged draft on top,
# this edit's validated fields last) so publish is a plain copy with no merge logic.
@@ -1717,6 +1750,7 @@ class HogFlowViewSet(
if route_to_draft:
self._write_draft(locked, locked, serializer.validated_data)
else:
+ self._refresh_action_redirects(locked, before_update, serializer.validated_data.get("actions"))
# save() mutates and returns `locked` in place, so it's the saved HogFlow from here on.
serializer.save()
@@ -1821,6 +1855,7 @@ class HogFlowViewSet(
# recompiles bytecode — a stored blob is never trusted to be execution-ready.
serializer = self.get_serializer(locked, data=dict(locked.draft), partial=True)
serializer.is_valid(raise_exception=True)
+ self._refresh_action_redirects(locked, before_update, serializer.validated_data.get("actions"))
serializer.save()
locked.draft = None
locked.draft_updated_at = None
diff --git a/products/workflows/backend/api/test/test_action_redirects.py b/products/workflows/backend/api/test/test_action_redirects.py
new file mode 100644
index 000000000000..58c6f1d39250
--- /dev/null
+++ b/products/workflows/backend/api/test/test_action_redirects.py
@@ -0,0 +1,165 @@
+from unittest import TestCase
+
+from parameterized import parameterized
+
+from products.workflows.backend.api.action_redirects import MAX_ACTION_REDIRECTS, compute_action_redirects
+
+
+def _actions(*ids: str) -> list[dict]:
+ # The type is arbitrary: compute_action_redirects only ever reads ids and edges. What kind of
+ # step was deleted can't matter - it was removed before the parked run executed it.
+ return [{"id": action_id, "type": "function", "config": {}} for action_id in ids]
+
+
+def _edge(frm: str, to: str, edge_type: str = "continue", index: int | None = None) -> dict:
+ edge: dict = {"from": frm, "to": to, "type": edge_type}
+ if index is not None:
+ edge["index"] = index
+ return edge
+
+
+# A linear graph: t -> a -> b -> c -> x
+LINEAR_EDGES = [_edge("t", "a"), _edge("a", "b"), _edge("b", "c"), _edge("c", "x")]
+
+
+class TestComputeActionRedirects(TestCase):
+ @parameterized.expand(
+ [
+ # Each case: (name, old_ids, old_edges, new_ids, existing_map, expected_map).
+ # The sketch above each case draws the OLD graph with the steps this edit deletes
+ # in [brackets]; the expected map is where runs parked on a deleted step go.
+ #
+ # t -> a -> [b] -> c -> x
+ (
+ "deleted_step_redirects_to_surviving_successor",
+ ["t", "a", "b", "c", "x"],
+ LINEAR_EDGES,
+ ["t", "a", "c", "x"],
+ None,
+ {"b": "c"},
+ ),
+ # t -> [a] -> [b] -> [c] -> x every deleted step walks to the first survivor
+ (
+ "chain_of_steps_deleted_in_one_edit_walks_to_first_survivor",
+ ["t", "a", "b", "c", "x"],
+ LINEAR_EDGES,
+ ["t", "x"],
+ None,
+ {"a": "x", "b": "x", "c": "x"},
+ ),
+ # t -> a -> [b] b was the last step: nothing after it, so no entry
+ # (runs parked on b take the graceful exit)
+ (
+ "dead_end_with_no_continue_edge_is_omitted",
+ ["t", "a", "b"],
+ [_edge("t", "a"), _edge("a", "b")],
+ ["t", "a"],
+ None,
+ None,
+ ),
+ # t -> a -> [b] -> [x] everything after b died too: no survivor, no entry
+ (
+ "everything_downstream_also_deleted_is_omitted",
+ ["t", "a", "b", "x"],
+ [_edge("t", "a"), _edge("a", "b"), _edge("b", "x")],
+ ["t", "a"],
+ None,
+ None,
+ ),
+ # t -> [cond] -branch-> targeted
+ # \---continue-> fallthrough
+ # the walk takes cond's continue fall-through, never a branch edge: the config
+ # that decided who qualifies for `targeted` died with the node
+ (
+ "deleted_branch_node_follows_continue_fallthrough_not_branch_edges",
+ ["t", "cond", "targeted", "fallthrough"],
+ [
+ _edge("t", "cond"),
+ _edge("cond", "targeted", edge_type="branch", index=0),
+ _edge("cond", "fallthrough"),
+ ],
+ ["t", "targeted", "fallthrough"],
+ None,
+ {"cond": "fallthrough"},
+ ),
+ # t -> [a] <-> [b] a and b point at each other: the walk detects the loop
+ # of deleted nodes, finds no survivor, and omits both
+ (
+ "cycle_of_deleted_nodes_terminates_and_is_omitted",
+ ["t", "a", "b"],
+ [_edge("t", "a"), _edge("a", "b"), _edge("b", "a")],
+ ["t"],
+ None,
+ None,
+ ),
+ # t -> [b] -> c -> x with prior map {a: b} from an earlier edit:
+ # b resolves to c, and the stale a->b entry is rewritten to a->c so a run
+ # parked two edits back still resolves in one lookup
+ (
+ "existing_entry_with_deleted_target_is_rewritten_through_this_edit",
+ ["t", "b", "c", "x"],
+ [_edge("t", "b"), _edge("b", "c"), _edge("c", "x")],
+ ["t", "c", "x"],
+ {"a": "b"},
+ {"a": "c", "b": "c"},
+ ),
+ # t -> a -> x with prior map {b: x}, and this edit re-adds a step named b:
+ # runs parked on b can execute it normally again, so the entry is pruned
+ (
+ "existing_entry_whose_key_was_readded_is_pruned",
+ ["t", "a", "x"],
+ [_edge("t", "a"), _edge("a", "x")],
+ ["t", "a", "b", "x"],
+ {"b": "x"},
+ None,
+ ),
+ # t -> [b] with prior map {a: b}: b dies as a dead end, so the a->b entry
+ # has nowhere to be rewritten and is dropped (those runs exit gracefully)
+ (
+ "existing_entry_whose_target_died_with_no_survivor_is_dropped",
+ ["t", "b"],
+ [_edge("t", "b")],
+ ["t"],
+ {"a": "b"},
+ None,
+ ),
+ # t -> b -> x nothing deleted: the prior {a: b} entry still points at a
+ # live step and is kept as-is
+ (
+ "no_deletions_preserves_existing_entries_with_live_targets",
+ ["t", "b", "x"],
+ [_edge("t", "b"), _edge("b", "x")],
+ ["t", "b", "x"],
+ {"a": "b"},
+ {"a": "b"},
+ ),
+ ]
+ )
+ def test_compute(self, _name, old_ids, old_edges, new_ids, existing, expected):
+ assert compute_action_redirects(_actions(*old_ids), old_edges, _actions(*new_ids), existing) == expected
+
+ def test_two_successive_edits_leave_a_run_two_edits_behind_one_lookup_away(self):
+ # A run parks on `a`. Edit 2 deletes `a` (map: a -> b). Edit 3 deletes `b`. The stored map
+ # must resolve `a` directly to `c` — the worker does exactly one lookup, never a chain.
+ after_edit_2 = compute_action_redirects(
+ _actions("t", "a", "b", "c", "x"), LINEAR_EDGES, _actions("t", "b", "c", "x"), None
+ )
+ assert after_edit_2 == {"a": "b"}
+
+ edges_after_edit_2 = [_edge("t", "b"), _edge("b", "c"), _edge("c", "x")]
+ after_edit_3 = compute_action_redirects(
+ _actions("t", "b", "c", "x"), edges_after_edit_2, _actions("t", "c", "x"), after_edit_2
+ )
+ assert after_edit_3 == {"a": "c", "b": "c"}
+
+ def test_map_is_capped_keeping_the_newest_entries(self):
+ # Churning uniquely-named steps can't grow the map without bound: over the cap, the oldest
+ # entries (prior edits) drop first and runs parked on them take the graceful exit.
+ existing = {f"old_{i}": "x" for i in range(MAX_ACTION_REDIRECTS)}
+ result = compute_action_redirects(
+ _actions("t", "a", "x"), [_edge("t", "a"), _edge("a", "x")], _actions("t", "x"), existing
+ )
+ assert result is not None
+ assert len(result) == MAX_ACTION_REDIRECTS
+ assert result["a"] == "x" # this edit's entry survives
+ assert "old_0" not in result # the oldest prior entry is the one dropped
diff --git a/products/workflows/backend/api/test/test_hog_flow_draft_publish.py b/products/workflows/backend/api/test/test_hog_flow_draft_publish.py
index d597ac661846..f80e48dd9c9b 100644
--- a/products/workflows/backend/api/test/test_hog_flow_draft_publish.py
+++ b/products/workflows/backend/api/test/test_hog_flow_draft_publish.py
@@ -391,6 +391,90 @@ class TestHogFlowDraftPublish(APIBaseTest):
assert response.json()["draft"] is not None
assert response.json()["draft_updated_at"] is not None
+ # ── Skip-forward redirects (deleted steps) ───────────────────────
+ # The redirect-walk matrix lives in test_action_redirects.py; these guard the viewset wiring —
+ # that each live-graph write path actually computes and persists the map before saving.
+
+ def _create_active_three_step_flow(self) -> str:
+ hog_flow = {
+ "name": "Redirect Flow",
+ "actions": [_trigger_action(), _webhook_action("action_1"), _webhook_action("action_2")],
+ "edges": [
+ {"from": "trigger_node", "to": "action_1", "type": "continue"},
+ {"from": "action_1", "to": "action_2", "type": "continue"},
+ ],
+ }
+ create = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert create.status_code == 201, create.json()
+ flow_id = create.json()["id"]
+ activate = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"status": "active"})
+ assert activate.status_code == 200, activate.json()
+ return flow_id
+
+ _DELETE_ACTION_1_PAYLOAD = {
+ "actions": [_trigger_action(), _webhook_action("action_2")],
+ "edges": [{"from": "trigger_node", "to": "action_2", "type": "continue"}],
+ }
+
+ @patch(FLAG_PATH, return_value=True)
+ def test_publish_deleting_a_step_persists_its_redirect(self, _flag):
+ flow_id = self._create_active_three_step_flow()
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
+ self._DELETE_ACTION_1_PAYLOAD,
+ HTTP_X_POSTHOG_CLIENT="mcp",
+ )
+ assert response.status_code == 200, response.json()
+ flow = HogFlow.objects.get(pk=flow_id)
+ assert flow.action_redirects is None, "staging a draft must not touch the live redirect map"
+ assert flow.draft_updated_at is not None
+
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/publish",
+ {"confirm": True, "draft_updated_at": flow.draft_updated_at.isoformat()},
+ )
+ assert response.status_code == 200, response.json()
+ # Re-fetch rather than refresh_from_db: the is-None assert above narrows the attribute
+ # type, and mypy doesn't un-narrow on refresh, flagging the asserts below as unreachable
+ flow = HogFlow.objects.get(pk=flow_id)
+ assert flow.action_redirects == {"action_1": "action_2"}
+ assert response.json()["workflow"]["action_redirects"] == {"action_1": "action_2"}
+
+ @parameterized.expand([("flag_on", True), ("flag_off", False)])
+ def test_web_edit_deleting_a_step_persists_its_redirect_only_when_flag_on(self, _name, flag_on):
+ flow_id = self._create_active_three_step_flow()
+ with patch(FLAG_PATH, return_value=flag_on):
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}", self._DELETE_ACTION_1_PAYLOAD
+ )
+ assert response.status_code == 200, response.json()
+ flow = HogFlow.objects.get(pk=flow_id)
+ assert flow.action_redirects == ({"action_1": "action_2"} if flag_on else None)
+
+ @patch(FLAG_PATH, return_value=True)
+ def test_edit_while_disabled_still_persists_its_redirect(self, _flag):
+ # Disabling a flow doesn't purge its parked runs — a step deleted during a disable/re-enable
+ # window must still get a redirect, or those runs strand on re-activation.
+ flow_id = self._create_active_three_step_flow()
+ disable = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"status": "draft"})
+ assert disable.status_code == 200, disable.json()
+
+ response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", self._DELETE_ACTION_1_PAYLOAD)
+ assert response.status_code == 200, response.json()
+ flow = HogFlow.objects.get(pk=flow_id)
+ assert flow.action_redirects == {"action_1": "action_2"}
+
+ @patch(FLAG_PATH, return_value=True)
+ def test_graph_remove_action_persists_its_redirect(self, _flag):
+ flow_id = self._create_active_three_step_flow()
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",
+ {"operations": [{"op": "remove_action", "id": "action_1"}]},
+ )
+ assert response.status_code == 200, response.json()
+ flow = HogFlow.objects.get(pk=flow_id)
+ assert flow.action_redirects == {"action_1": "action_2"}
+
@patch(FLAG_PATH, return_value=True)
def test_draft_contents_are_masked_in_activity_log(self, _flag):
flow_id = self._create_active_flow()
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index 9a5ca4f32ca1..e0ebb03ca83f 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -331,6 +331,12 @@ export interface PaginatedHogFlowMinimalListApi {
*/
export type HogFlowApiVariablesItem = { [key: string]: string }
+/**
+ * Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.
+ * @nullable
+ */
+export type HogFlowApiActionRedirects = { [key: string]: string } | null
+
export interface HogFlowConversionEventApi {
/** Event/action filters for this conversion event, same shape as trigger filters: {events: [{id, name, type: 'events', properties?: [<cond>]}], actions?: [...], properties?: [<cond>]}. bytecode is compiled server-side. */
filters: HogFunctionFiltersApi
@@ -402,7 +408,10 @@ export type HogFlowActionApiConfig =
}
export interface HogFlowActionApi {
- /** Unique node ID within the workflow. */
+ /**
+ * Unique node ID within the workflow.
+ * @maxLength 200
+ */
id: string
/**
* Display name.
@@ -533,6 +542,11 @@ export interface HogFlowApi {
* @nullable
*/
readonly draft_updated_at: string | null
+ /**
+ * Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.
+ * @nullable
+ */
+ readonly action_redirects: HogFlowApiActionRedirects
}
/**
@@ -540,6 +554,12 @@ export interface HogFlowApi {
*/
export type PatchedHogFlowApiVariablesItem = { [key: string]: string }
+/**
+ * Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.
+ * @nullable
+ */
+export type PatchedHogFlowApiActionRedirects = { [key: string]: string } | null
+
/**
* Mixin for serializers to add user access control fields
*/
@@ -598,6 +618,11 @@ export interface PatchedHogFlowApi {
* @nullable
*/
readonly draft_updated_at?: string | null
+ /**
+ * Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.
+ * @nullable
+ */
+ readonly action_redirects?: PatchedHogFlowApiActionRedirects
}
export interface MessageAssetApi {
diff --git a/products/workflows/frontend/generated/api.zod.ts b/products/workflows/frontend/generated/api.zod.ts
index 6c3f9732fb25..55c95726e73d 100644
--- a/products/workflows/frontend/generated/api.zod.ts
+++ b/products/workflows/frontend/generated/api.zod.ts
@@ -389,6 +389,8 @@ export const hogFlowsCreateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsCreateBodyTriggerMaskingOneTtlMax = 94608000
export const hogFlowsCreateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`
+export const hogFlowsCreateBodyActionsItemIdMax = 200
+
export const hogFlowsCreateBodyActionsItemNameMax = 400
export const hogFlowsCreateBodyActionsItemDescriptionDefault = ``
@@ -532,7 +534,10 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod
actions: zod
.array(
zod.object({
- id: zod.string().describe('Unique node ID within the workflow.'),
+ id: zod
+ .string()
+ .max(hogFlowsCreateBodyActionsItemIdMax)
+ .describe('Unique node ID within the workflow.'),
name: zod.string().max(hogFlowsCreateBodyActionsItemNameMax).describe('Display name.'),
description: zod
.string()
@@ -714,6 +719,8 @@ export const hogFlowsUpdateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsUpdateBodyTriggerMaskingOneTtlMax = 94608000
export const hogFlowsUpdateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`
+export const hogFlowsUpdateBodyActionsItemIdMax = 200
+
export const hogFlowsUpdateBodyActionsItemNameMax = 400
export const hogFlowsUpdateBodyActionsItemDescriptionDefault = ``
@@ -857,7 +864,10 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zod
actions: zod
.array(
zod.object({
- id: zod.string().describe('Unique node ID within the workflow.'),
+ id: zod
+ .string()
+ .max(hogFlowsUpdateBodyActionsItemIdMax)
+ .describe('Unique node ID within the workflow.'),
name: zod.string().max(hogFlowsUpdateBodyActionsItemNameMax).describe('Display name.'),
description: zod
.string()
@@ -1039,6 +1049,8 @@ export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax = 94608000
export const hogFlowsPartialUpdateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`
+export const hogFlowsPartialUpdateBodyActionsItemIdMax = 200
+
export const hogFlowsPartialUpdateBodyActionsItemNameMax = 400
export const hogFlowsPartialUpdateBodyActionsItemDescriptionDefault = ``
@@ -1187,7 +1199,10 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod
actions: zod
.array(
zod.object({
- id: zod.string().describe('Unique node ID within the workflow.'),
+ id: zod
+ .string()
+ .max(hogFlowsPartialUpdateBodyActionsItemIdMax)
+ .describe('Unique node ID within the workflow.'),
name: zod.string().max(hogFlowsPartialUpdateBodyActionsItemNameMax).describe('Display name.'),
description: zod
.string()
@@ -1481,6 +1496,8 @@ export const hogFlowsInvocationsCreateBodyConfigurationOneTriggerMaskingOneTtlMi
export const hogFlowsInvocationsCreateBodyConfigurationOneTriggerMaskingOneTtlMax = 94608000
export const hogFlowsInvocationsCreateBodyConfigurationOneConversionOneEventsItemFiltersOneSourceDefault = `events`
+export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemIdMax = 200
+
export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemNameMax = 400
export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemDescriptionDefault = ``
@@ -1684,7 +1701,10 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({
actions: zod
.array(
zod.object({
- id: zod.string().describe('Unique node ID within the workflow.'),
+ id: zod
+ .string()
+ .max(hogFlowsInvocationsCreateBodyConfigurationOneActionsItemIdMax)
+ .describe('Unique node ID within the workflow.'),
name: zod
.string()
.max(hogFlowsInvocationsCreateBodyConfigurationOneActionsItemNameMax)
@@ -1922,6 +1942,12 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({
.describe(
"When the draft was last written; null when there's no staged draft. Pass this to publish (and as base_updated_at on further draft edits) so a concurrent editor's changes aren't clobbered — a mismatch returns 409."
),
+ action_redirects: zod
+ .record(zod.string(), zod.string())
+ .nullable()
+ .describe(
+ 'Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.'
+ ),
})
.describe('Mixin for serializers to add user access control fields')
.optional()
@@ -2081,6 +2107,8 @@ export const hogFlowsBulkDeleteCreateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsBulkDeleteCreateBodyTriggerMaskingOneTtlMax = 94608000
export const hogFlowsBulkDeleteCreateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`
+export const hogFlowsBulkDeleteCreateBodyActionsItemIdMax = 200
+
export const hogFlowsBulkDeleteCreateBodyActionsItemNameMax = 400
export const hogFlowsBulkDeleteCreateBodyActionsItemDescriptionDefault = ``
@@ -2229,7 +2257,10 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zod
actions: zod
.array(
zod.object({
- id: zod.string().describe('Unique node ID within the workflow.'),
+ id: zod
+ .string()
+ .max(hogFlowsBulkDeleteCreateBodyActionsItemIdMax)
+ .describe('Unique node ID within the workflow.'),
name: zod.string().max(hogFlowsBulkDeleteCreateBodyActionsItemNameMax).describe('Display name.'),
description: zod
.string()
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index b23e7543a861..fe259c438989 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -29850,6 +29850,12 @@ export namespace Schemas {
*/
export type HogFlowVariablesItem = {[key: string]: string};
+ /**
+ * Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.
+ * @nullable
+ */
+ export type HogFlowActionRedirects = {[key: string]: string} | null;
+
/**
* * `draft` - Draft
* * `active` - Active
@@ -29999,7 +30005,10 @@ export namespace Schemas {
};
export interface HogFlowAction {
- /** Unique node ID within the workflow. */
+ /**
+ * Unique node ID within the workflow.
+ * @maxLength 200
+ */
id: string;
/**
* Display name.
@@ -30130,6 +30139,11 @@ export namespace Schemas {
* @nullable
*/
readonly draft_updated_at: string | null;
+ /**
+ * Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.
+ * @nullable
+ */
+ readonly action_redirects: HogFlowActionRedirects;
}
/**
@@ -45240,6 +45254,12 @@ export namespace Schemas {
*/
export type PatchedHogFlowVariablesItem = {[key: string]: string};
+ /**
+ * Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.
+ * @nullable
+ */
+ export type PatchedHogFlowActionRedirects = {[key: string]: string} | null;
+
/**
* Mixin for serializers to add user access control fields
*/
@@ -45298,6 +45318,11 @@ export namespace Schemas {
* @nullable
*/
readonly draft_updated_at?: string | null;
+ /**
+ * Skip-forward map for deleted steps: {deleted_action_id: next surviving action_id}. Maintained automatically when a live graph edit deletes actions, so in-flight runs parked on a deleted step continue at its surviving successor instead of exiting. Null when no live deletions have occurred.
+ * @nullable
+ */
+ readonly action_redirects?: PatchedHogFlowActionRedirects;
}
export interface PatchedHogFlowGraphUpdate {
diff --git a/services/mcp/src/generated/workflows/api.ts b/services/mcp/src/generated/workflows/api.ts
index 0b3642ca3526..e43ec93434d1 100644
--- a/services/mcp/src/generated/workflows/api.ts
+++ b/services/mcp/src/generated/workflows/api.ts
@@ -44,6 +44,8 @@ export const hogFlowsCreateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsCreateBodyTriggerMaskingOneTtlMax = 94608000
export const hogFlowsCreateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`
+export const hogFlowsCreateBodyActionsItemIdMax = 200
+
export const hogFlowsCreateBodyActionsItemNameMax = 400
export const hogFlowsCreateBodyActionsItemDescriptionDefault = ``
@@ -187,7 +189,10 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod
actions: zod
.array(
zod.object({
- id: zod.string().describe('Unique node ID within the workflow.'),
+ id: zod
+ .string()
+ .max(hogFlowsCreateBodyActionsItemIdMax)
+ .describe('Unique node ID within the workflow.'),
name: zod.string().max(hogFlowsCreateBodyActionsItemNameMax).describe('Display name.'),
description: zod
.string()
@@ -386,6 +391,8 @@ export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax = 94608000
export const hogFlowsPartialUpdateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`
+export const hogFlowsPartialUpdateBodyActionsItemIdMax = 200
+
export const hogFlowsPartialUpdateBodyActionsItemNameMax = 400
export const hogFlowsPartialUpdateBodyActionsItemDescriptionDefault = ``
@@ -524,7 +531,10 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod
actions: zod
.array(
zod.object({
- id: zod.string().describe('Unique node ID within the workflow.'),
+ id: zod
+ .string()
+ .max(hogFlowsPartialUpdateBodyActionsItemIdMax)
+ .describe('Unique node ID within the workflow.'),
name: zod.string().max(hogFlowsPartialUpdateBodyActionsItemNameMax).describe('Display name.'),
description: zod
.string()
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 cd585f968563..72b340a500ca 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json
@@ -273,6 +273,7 @@
},
"id": {
"description": "Unique node ID within the workflow.",
+ "maxLength": 200,
"type": "string"
},
"name": {
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json
index 3966e0e19bab..9b9ea7ea2ba5 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json
@@ -272,6 +272,7 @@
},
"id": {
"description": "Unique node ID within the workflow.",
+ "maxLength": 200,
"type": "string"
},
"name": {