{"record":{"id":"49f7c5b3be110cf0","repo":"n8n-io/n8n","slug":"failed-to-load-existing-workflow-workflowid-to-49f7c5","errorCode":null,"errorMessage":"Failed to load existing workflow ${workflowId} to preserve node-group IDs: ${message}","messagePattern":"Failed to load existing workflow (.+?) to preserve node-group IDs: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts","lineNumber":188,"sourceCode":" * ID for every group — overwriting the stable ID of a group the user created in\n * the editor. Reconciling by name here keeps it stable, mirroring ensureWebhookIds.\n */\nexport async function preserveExistingNodeGroupIds(\n\tjson: WorkflowJSON,\n\tworkflowId: string | undefined,\n\tctx: InstanceAiContext,\n): Promise<void> {\n\tif (!workflowId || !json.nodeGroups?.length) return;\n\n\tlet existingGroupIdsByName: Map<string, string>;\n\ttry {\n\t\tconst existing = await ctx.workflowService.getAsWorkflowJSON(workflowId);\n\t\texistingGroupIdsByName = new Map(\n\t\t\t(existing.nodeGroups ?? []).map((group): [string, string] => [group.name, group.id]),\n\t\t);\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-group IDs: ${message}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\n\tfor (const group of json.nodeGroups) {\n\t\tconst existingId = existingGroupIdsByName.get(group.name);\n\t\tif (existingId) {\n\t\t\tgroup.id = existingId;\n\t\t}\n\t}\n}\n\ntype WorkflowParameterValue = IDataObject[string];\n\nfunction isDataObject(value: WorkflowParameterValue): value is IDataObject {\n\treturn value !== null && typeof value === 'object' && !Array.isArray(value);\n}","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts#L170-L206","documentation":"Error \"Failed to load existing workflow ${workflowId} to preserve node-group IDs: ${message}\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts:188 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-13T04:17:16.726Z"}