{"record":{"id":"1877d05380168acf","repo":"twentyhq/twenty","slug":"couldn-t-duplicate-step","errorCode":null,"errorMessage":"Couldn't duplicate step","messagePattern":"Couldn't duplicate step","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-front/src/modules/workflow/workflow-steps/hooks/useDuplicateStep.ts","lineNumber":44,"sourceCode":"    }\n\n    setIsLoading(true);\n\n    try {\n      const workflowVersionId = await getUpdatableWorkflowVersion();\n\n      const workflowVersionStepChanges = (\n        await duplicateWorkflowVersionStep({\n          workflowVersionId,\n          stepId,\n        })\n      )?.data?.duplicateWorkflowVersionStep;\n\n      const stepsDiff = workflowVersionStepChanges?.stepsDiff as Difference[];\n      const createdStepDiff = stepsDiff?.find((diff) => diff.type === 'CREATE');\n\n      if (!isDefined(createdStepDiff)) {\n        throw new Error(\"Couldn't duplicate step\");\n      }\n\n      setWorkflowSelectedNode(createdStepDiff.value.id);\n      setWorkflowLastCreatedStepId(createdStepDiff.value.id);\n\n      return createdStepDiff.value;\n    } finally {\n      setIsLoading(false);\n    }\n  };\n\n  return {\n    duplicateStep,\n  };\n};\n","sourceCodeStart":26,"sourceCodeEnd":60,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-front/src/modules/workflow/workflow-steps/hooks/useDuplicateStep.ts#L26-L60","documentation":"Thrown in useDuplicateStep after duplicateWorkflowVersionStep returns: the stepsDiff has no entry with type 'CREATE'. The backend did not produce a new step in the diff, so the duplication effectively did not happen client-side.","triggerScenarios":"stepId no longer exists (deleted before duplicate completed). Backend validation failure (permission, version not editable) returning a 200 with no-op diff. Diff shape change. Concurrent edit collapsed the source step.","commonSituations":"User double-clicks duplicate while the step is being removed. Permissions disallow step creation. Version was published between the open and the duplicate action.","solutions":["Inspect the duplicateWorkflowVersionStep response (data + errors).","Verify stepId still exists in the current workflow graph at call time.","Confirm the workflow version is editable (DRAFT)."],"exampleFix":"// before: if (!isDefined(createdStepDiff)) { throw new Error(\"Couldn't duplicate step\"); }\n// after:  if (!isDefined(createdStepDiff)) {\n//           throw new Error(workflowVersionStepChanges?.errors?.[0]?.message ?? \"Couldn't duplicate step\");\n//         }","handlingStrategy":"try-catch","validationCode":"const canDuplicateStep = (stepId: string, knownStepIds: Set<string>): boolean =>\n  knownStepIds.has(stepId);","typeGuard":"const hasDuplicateCreateDiff = (diff: Difference[] | undefined): boolean =>\n  Array.isArray(diff) && diff.some((d) => d.type === 'CREATE');","tryCatchPattern":"try {\n  await duplicateStep({ stepId });\n} catch (e) {\n  showError((e as Error).message); // \"Couldn't duplicate step\"\n}","preventionTips":["Refresh the workflow graph before duplicating to avoid stale stepIds.","Disable the duplicate action while a deletion is in flight.","Confirm the version is editable (DRAFT) before attempting duplication."],"tags":["workflow","graphql","apollo"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}