{"record":{"id":"b27e557c65cd3b45","repo":"n8n-io/n8n","slug":"failed-to-load-existing-workflow-workflowid-to-b27e55","errorCode":null,"errorMessage":"Failed to load existing workflow ${workflowId} to preserve webhook IDs: ${message}","messagePattern":"Failed to load existing workflow (.+?) to preserve webhook IDs: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts","lineNumber":153,"sourceCode":" * For updates, preserve existing webhookIds by node name so URLs remain stable.\n */\nexport async function ensureWebhookIds(\n\tjson: WorkflowJSON,\n\tworkflowId: string | undefined,\n\tctx: InstanceAiContext,\n): Promise<void> {\n\tconst existingWebhookIds = new Map<string, string>();\n\tif (workflowId) {\n\t\ttry {\n\t\t\tconst existing = await ctx.workflowService.getAsWorkflowJSON(workflowId);\n\t\t\tfor (const node of existing.nodes ?? []) {\n\t\t\t\tif (node.webhookId && node.name) {\n\t\t\t\t\texistingWebhookIds.set(node.name, node.webhookId);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to load existing workflow ${workflowId} to preserve webhook IDs: ${message}`,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const node of json.nodes ?? []) {\n\t\tif (WEBHOOK_NODE_TYPES.has(node.type) && !node.webhookId) {\n\t\t\tnode.webhookId = (node.name && existingWebhookIds.get(node.name)) ?? randomUUID();\n\t\t}\n\t}\n}\n\n/**\n * For updates, preserve existing node-group IDs by group name. The sandbox SDK\n * build has no view of the saved workflow, so toJSON() mints a fresh deterministic\n * 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.","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts#L135-L171","documentation":"ensureWebhookIds attempted to load the existing workflow to carry webhookIds over by node name (keeping URLs stable across rebuilds), but the load threw. The failure is surfaced with the underlying message so the caller knows IDs could not be preserved rather than being silently regenerated.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts:153 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the workflow id exists and the service can read it","Retry after fixing the underlying load error so webhook IDs can be reconciled"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","contentChangedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}