windmill-labs/windmill · error

Step with id "${stepId}" not found in flow. Available steps:

Error message

Step with id "${stepId}" not found in flow. Available steps: ${getAvailableFlowStepIds(flowValue)}

What it means

Flow step tools (e.g. editing or testing a specific step) resolve the requested stepId within the current flow value. When no module with that id exists, the tool throws an error listing the ids that DO exist via getAvailableFlowStepIds, so the model can pick a valid one. A tool status with 'Step "X" not found in flow' is also recorded.

Source

Thrown at frontend/src/lib/components/copilot/chat/shared.ts:1904

	flowValue,
	stepId,
	args,
	workspace,
	toolCallbacks,
	toolId,
	background,
	detachAfterMs,
	loadScript = loadDeployedScriptForFlowStep,
	loadFlowPreviewValue
}: FlowStepTestRunConfig): Promise<string> {
	const targetModule = findModuleInFlow(flowValue, stepId) ?? undefined

	if (!targetModule) {
		toolCallbacks.setToolStatus(toolId, {
			content: `Step "${stepId}" not found in flow`,
			error: `Step with id "${stepId}" does not exist in the current flow`
		})
		throw new Error(
			`Step with id "${stepId}" not found in flow. Available steps: ${getAvailableFlowStepIds(flowValue)}`
		)
	}

	const moduleValue = targetModule.value
	const stepArgs = normalizeFlowStepArgs(args)

	if (moduleValue.type === 'rawscript') {
		return executeTestRun({
			jobStarter: () =>
				JobService.runScriptPreview({
					workspace,
					requestBody: {
						content: moduleValue.content ?? '',
						language: moduleValue.language,
						args: flowStepArgsForModule(targetModule.id, stepArgs)
					}
				}),

View on GitHub (pinned to e474e8803c)

Solutions

  1. Retry the tool call using one of the ids printed in 'Available steps: [...]' (also visible via getFlowStepIds from the current flow value).
  2. Re-read the current flow JSON (update_flow_value / fresh flow load) to refresh step ids, then target the correct one.
  3. If the step was deleted, recreate it or ask the model to add a new step instead of editing the missing one.
  4. Confirm the chat is operating on the intended flow — a stale context may not contain the step you mean.

Example fix

// before
{"name": "test_flow_step", "arguments": {"step_id": "step_1"}} // not found
// after
{"name": "test_flow_step", "arguments": {"step_id": "a1b2c3"}} // id from Available steps list
Defensive patterns

Strategy: validation

Validate before calling

const stepIds = (flowValue?.modules?.roots ?? []).map((m) => m?.value?.id).filter(Boolean)
if (!stepIds.includes(stepId)) {
  throw new Error(`step_id must be one of: ${stepIds.join(', ')}`) // fail fast with valid options
}

Type guard

function isValidStepId(flowValue: { modules?: { roots?: Array<{ value?: { id?: string } }> } } | null, stepId: string): boolean {
  return !!flowValue?.modules?.roots?.some((m) => m?.value?.id === stepId)
}

Try / catch

try {
  await testFlowStep({ stepId, ... })
} catch (e) {
  const m = e.message.match(/Available steps: \[(.*)\]/)
  if (m) {
    const validIds = m[1].split(', ').map((s) => s.replace(/"/g, ''))
    // retry with a valid id, or surface the list to the user
  }
}

Prevention

When it happens

Trigger: The model called a step-targeted tool with a step id that does not exist in the loaded flow — typically a hallucinated/renamed id, an id from a different flow version, or an empty/failed flow load leaving flowValue without the expected modules.

Common situations: The flow was edited (step deleted or id regenerated) after the model read it; the model invented an id like 'step_1' instead of using the real ids; the chat context holds a stale flow JSON; user pasted a step name instead of its id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/7c0bc7b5a6102c76. Report an issue: GitHub.