n8n-io/n8n · error

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

Error message

Failed to load existing workflow ${workflowId} to preserve node-group IDs: ${message}

What it means

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

Source

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

 * ID for every group — overwriting the stable ID of a group the user created in
 * the editor. Reconciling by name here keeps it stable, mirroring ensureWebhookIds.
 */
export async function preserveExistingNodeGroupIds(
	json: WorkflowJSON,
	workflowId: string | undefined,
	ctx: InstanceAiContext,
): Promise<void> {
	if (!workflowId || !json.nodeGroups?.length) return;

	let existingGroupIdsByName: Map<string, string>;
	try {
		const existing = await ctx.workflowService.getAsWorkflowJSON(workflowId);
		existingGroupIdsByName = new Map(
			(existing.nodeGroups ?? []).map((group): [string, string] => [group.name, group.id]),
		);
	} catch (error) {
		const message = error instanceof Error ? error.message : String(error);
		throw new Error(
			`Failed to load existing workflow ${workflowId} to preserve node-group IDs: ${message}`,
			{ cause: error },
		);
	}

	for (const group of json.nodeGroups) {
		const existingId = existingGroupIdsByName.get(group.name);
		if (existingId) {
			group.id = existingId;
		}
	}
}

type WorkflowParameterValue = IDataObject[string];

function isDataObject(value: WorkflowParameterValue): value is IDataObject {
	return value !== null && typeof value === 'object' && !Array.isArray(value);
}

View on GitHub (pinned to 5ac6606e81)

When it happens

Trigger: Thrown at packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts:188 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/49f7c5b3be110cf0. Report an issue: GitHub.