{"record":{"id":"d9acf79b312fbdc7","repo":"n8n-io/n8n","slug":"failed-to-load-existing-workflow-workflowid-to","errorCode":null,"errorMessage":"Failed to load existing workflow ${workflowId} to preserve node positions: ${message}","messagePattern":"Failed to load existing workflow (.+?) to preserve node positions: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/tools/workflows/preserve-node-positions.ts","lineNumber":192,"sourceCode":" * engine put it — scattering a canvas the user had arranged by hand. Reconciling by\n * name here keeps the user's layout authoritative, mirroring ensureWebhookIds.\n *\n * Nodes the build added are translated into the saved canvas's frame, keeping the\n * layout engine's relative arrangement, then nudged clear of anything they land on.\n */\nexport async function preserveExistingNodePositions(\n\tjson: WorkflowJSON,\n\tworkflowId: string | undefined,\n\tctx: InstanceAiContext,\n): Promise<void> {\n\tif (!workflowId) return;\n\n\tlet existing: WorkflowJSON;\n\ttry {\n\t\texisting = await ctx.workflowService.getAsWorkflowJSON(workflowId);\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t`Failed to load existing workflow ${workflowId} to preserve node positions: ${message}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\n\tconst savedPositionsByName = new Map<string, Position>();\n\tfor (const node of existing.nodes ?? []) {\n\t\tif (node.name && Array.isArray(node.position)) {\n\t\t\tsavedPositionsByName.set(node.name, [node.position[0], node.position[1]]);\n\t\t}\n\t}\n\tif (savedPositionsByName.size === 0) return;\n\n\tconst nodes = json.nodes ?? [];\n\tconst survivors: Survivor[] = [];\n\tconst added: NodeJSON[] = [];\n\tfor (const node of nodes) {\n\t\tconst saved = node.name ? savedPositionsByName.get(node.name) : undefined;","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/tools/workflows/preserve-node-positions.ts#L174-L210","documentation":"Error \"Failed to load existing workflow ${workflowId} to preserve node positions: ${message}\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/tools/workflows/preserve-node-positions.ts:192 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}