n8n-io/n8n · error

Failed to load existing workflow

Error message

Failed to load existing workflow ${workflowId} to preserve setup values: ${message}

What it means

preserveExistingSetupValues loads the saved workflow to re-apply user-entered setup-card values onto matching placeholders in a rebuilt source file. When that load fails, the error is rethrown with the workflow id and cause, because dropping it would silently discard the user's runtime setup values.

Solutions

  1. Fix the underlying workflow load failure (id validity, permissions, service health)
  2. Re-enter the setup values after a successful rebuild if the saved workflow is gone
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts:307 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts:307

/**
 * Preserve user-provided setup values when a source-file rebuild still contains
 * the same placeholder. The source file owns structure; the saved workflow owns
 * runtime setup collected through the setup card.
 */
export async function preserveExistingSetupValues(
	json: WorkflowJSON,
	workflowId: string | undefined,
	ctx: InstanceAiContext,
): Promise<void> {
	if (!workflowId) return;

	let existing: WorkflowJSON;
	try {
		existing = await ctx.workflowService.getAsWorkflowJSON(workflowId);
	} catch (error) {
		const message = error instanceof Error ? error.message : String(error);
		throw new Error(
			`Failed to load existing workflow ${workflowId} to preserve setup values: ${message}`,
			{ cause: error },
		);
	}

	const existingNodesByNameAndType = new Map(
		(existing.nodes ?? [])
			.filter((node) => node.name && node.type)
			.map((node) => [`${node.type}:${node.name}`, node]),
	);

	for (const node of json.nodes ?? []) {
		if (!node.name || !node.type || !node.parameters) continue;

		const existingNode = existingNodesByNameAndType.get(`${node.type}:${node.name}`);
		if (!existingNode?.parameters) continue;

		node.parameters = preserveParameterValues(node.parameters, existingNode.parameters);

View on GitHub (pinned to 5ac6606e81)