n8n-io/n8n · error

Failed to load existing workflow ${workflowId} to preserve s

Error message

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

What it means

Error "Failed to load existing workflow ${workflowId} to preserve setup values: ${message}" thrown in n8n-io/n8n.

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)

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.