n8n-io/n8n · warning · WorkflowActivationError

Failed to find workflow with ID "${workflowId}"

Error message

Failed to find workflow with ID "${workflowId}"

What it means

Thrown by ActiveWorkflowManager.add() when activating/publishing a workflow: it looks up the workflow by ID in the database (or accepts a passed-in entity), and if none is found it throws a WorkflowActivationError at 'warning' level. This typically means the workflow was deleted between a request to activate it and the activation attempt, or the ID is wrong/stale.

Source

Thrown at packages/cli/src/active-workflow-manager.ts:534

	 * Active triggers, poll triggers, and schedule triggers are registered as
	 * active in memory at `ActiveWorkflowTriggers`, but webhook triggers are registered
	 * by being entered in the `webhook_entity` table, since webhooks do not
	 * require continuous execution.
	 *
	 * Returns whether this operation added webhooks and/or non-webhook triggers.
	 */
	async add(
		workflowId: WorkflowId,
		activationMode: WorkflowActivateMode,
		existingWorkflow?: WorkflowEntity,
		{ shouldPublish } = { shouldPublish: true },
	) {
		const added = { webhooks: false, triggersAndPollers: false };

		const dbWorkflow = existingWorkflow ?? (await this.workflowRepository.findById(workflowId));

		if (!dbWorkflow) {
			throw new WorkflowActivationError(`Failed to find workflow with ID "${workflowId}"`, {
				level: 'warning',
			});
		}

		if (dbWorkflow.isArchived) {
			this.logger.debug('Cannot publish archived Workflow', { workflowId: dbWorkflow.id });
			return added;
		}

		if (this.instanceSettings.isMultiMain && shouldPublish) {
			if (!dbWorkflow?.activeVersionId) {
				throw new UnexpectedError('Active version ID not found for workflow', {
					extra: { workflowId },
				});
			}

			void this.publisher.publishCommand({
				command: 'add-webhooks-triggers-and-pollers',

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Verify the workflow exists: re-fetch the workflow list and confirm the ID before activating.
  2. If the workflow was deleted, inform the user and remove the stale reference (e.g. discard the cached ID).
  3. Handle the WorkflowActivationError at the call site and surface a 'workflow not found' message rather than retrying.

Example fix

// before
await activeWorkflowManager.add(workflowId, 'activate');

// after
const wf = await workflowRepository.findById(workflowId);
if (!wf) throw new NotFoundError(`Workflow ${workflowId} not found`);
await activeWorkflowManager.add(workflowId, 'activate', wf);
Defensive patterns

Strategy: validation

Validate before calling

const wf = await workflowRepository.findById(workflowId);
if (!wf) {
  throw new NotFoundError(`Workflow ${workflowId} not found`);
}
await activeWorkflowManager.add(workflowId, 'activate', wf);

Type guard

function workflowExists(wf: unknown): wf is WorkflowEntity {
  return wf != null;
}

Try / catch

try {
  await activeWorkflowManager.add(workflowId, 'activate');
} catch (e) {
  if (e instanceof WorkflowActivationError && /Failed to find workflow/.test(e.message)) {
    // surface 'not found' to user; do not retry
    return { status: 404 };
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the activation path (PUT /workflows/:id/activate, manual activate, or startup activation of active workflows) for an ID that no longer exists in the workflow table; passing a stale ID from a cached client; race where another user deletes the workflow concurrently.

Common situations: UI shows a workflow that was deleted in another tab/session; startup re-activation of a workflow removed while the instance was down; API client caching an ID past deletion; imported/Restored backup referencing missing IDs.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/c01685fa56c8e1fa. Report an issue: GitHub.