{"record":{"id":"0add39692972210c","repo":"n8n-io/n8n","slug":"failed-to-load-existing-workflow-workflowid-to-0add39","errorCode":null,"errorMessage":"Failed to load existing workflow ${workflowId} to preserve setup values: ${message}","messagePattern":"Failed to load existing workflow (.+?) to preserve setup values: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts","lineNumber":307,"sourceCode":"\n/**\n * Preserve user-provided setup values when a source-file rebuild still contains\n * the same placeholder. The source file owns structure; the saved workflow owns\n * runtime setup collected through the setup card.\n */\nexport async function preserveExistingSetupValues(\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 setup values: ${message}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\n\tconst existingNodesByNameAndType = new Map(\n\t\t(existing.nodes ?? [])\n\t\t\t.filter((node) => node.name && node.type)\n\t\t\t.map((node) => [`${node.type}:${node.name}`, node]),\n\t);\n\n\tfor (const node of json.nodes ?? []) {\n\t\tif (!node.name || !node.type || !node.parameters) continue;\n\n\t\tconst existingNode = existingNodesByNameAndType.get(`${node.type}:${node.name}`);\n\t\tif (!existingNode?.parameters) continue;\n\n\t\tnode.parameters = preserveParameterValues(node.parameters, existingNode.parameters);","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts#L289-L325","documentation":"preserveExistingSetupValues loads the saved workflow to re-apply user-entered setup-card values onto matching placeholders in a rebuilt source file. When that load fails, the error is rethrown with the workflow id and cause, because dropping it would silently discard the user's runtime setup values.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/tools/workflows/workflow-json-utils.ts:307 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the underlying workflow load failure (id validity, permissions, service health)","Re-enter the setup values after a successful rebuild if the saved workflow is gone"],"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"}