{"record":{"id":"1c4f32d6710f04b3","repo":"twentyhq/twenty","slug":"couldn-t-create-step","errorCode":null,"errorMessage":"Couldn't create step","messagePattern":"Couldn't create step","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-front/src/modules/workflow/workflow-steps/hooks/useCreateStep.ts","lineNumber":85,"sourceCode":"          nextStepId,\n          position,\n          parentStepConnectionOptions: connectionOptions,\n          defaultSettings,\n        })\n      )?.data?.createWorkflowVersionStep;\n\n      const stepsDiff = workflowVersionStepChanges?.stepsDiff as Difference[];\n\n      const addedStepDiff = stepsDiff?.find(\n        (diff) => diff.type === 'CREATE' && diff.value.id === id,\n      ) as Nullable<DifferenceCreate>;\n\n      const createdFirstStepDiff = stepsDiff?.find(\n        (diff) => diff.type === 'CHANGE' && diff.value?.[0]?.id === id,\n      ) as Nullable<DifferenceChange>;\n\n      if (!isDefined(createdFirstStepDiff) && !isDefined(addedStepDiff)) {\n        throw new Error(\"Couldn't create step\");\n      }\n\n      if (shouldSelectNode) {\n        setWorkflowSelectedNode(id);\n      }\n      setWorkflowLastCreatedStepId(id);\n\n      return isDefined(createdFirstStepDiff)\n        ? createdFirstStepDiff.value[0]\n        : addedStepDiff?.value;\n    } finally {\n      setIsLoading(false);\n    }\n  };\n\n  return {\n    createStep,\n  };","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-front/src/modules/workflow/workflow-steps/hooks/useCreateStep.ts#L67-L103","documentation":"Thrown in useCreateStep after createWorkflowVersionStep returns: the stepsDiff contains neither a CREATE entry whose value.id matches the new step id, nor a CHANGE entry containing that id. The backend did not register the new step in the returned diff.","triggerScenarios":"Backend rejects the new step (invalid newStepType, parentStepId pointing to a nonexistent step, version in a non-editable state) and returns a 200 with an empty/no-op diff. The returned diff shape differs from expectations. Concurrent edit already removed the parent.","commonSituations":"Invalid step type. parentStepId/nextStepId stale after another edit. Workflow version locked or already published. Backend bug returning an unchanged diff on success.","solutions":["Inspect the createWorkflowVersionStep GraphQL response (data + errors) in DevTools.","Confirm newStepType is a valid WorkflowActionType and parentStepId/nextStepId reference existing steps.","Ensure the workflow version is a DRAFT (getUpdatableWorkflowVersion resolved); if not, a draft creation may have silently failed upstream."],"exampleFix":"// before: if (!isDefined(createdFirstStepDiff) && !isDefined(addedStepDiff)) {\n//           throw new Error(\"Couldn't create step\");\n//         }\n// after:  if (!isDefined(createdFirstStepDiff) && !isDefined(addedStepDiff)) {\n//           throw new Error(workflowVersionStepChanges?.errors?.[0]?.message ?? \"Couldn't create step\");\n//         }","handlingStrategy":"try-catch","validationCode":"const isValidCreateStepInput = (\n  stepType: WorkflowActionType,\n  parentStepId: string | undefined,\n  existingStepIds: Set<string>,\n): boolean =>\n  typeof stepType === 'string' && (parentStepId === undefined || existingStepIds.has(parentStepId));","typeGuard":"const hasCreateStepDiff = (diff: Difference[] | undefined, id: string): boolean =>\n  Array.isArray(diff) && diff.some((d) => d.type === 'CREATE' && (d as any).value?.id === id);","tryCatchPattern":"try {\n  await createStep({ newStepType, parentStepId, nextStepId, ... });\n} catch (e) {\n  showError((e as Error).message); // \"Couldn't create step\"\n}","preventionTips":["Confirm parentStepId/nextStepId reference current steps at call time.","Guard against double-submission via the existing isLoading flag.","Surface backend errors so the generic throw is a last resort."],"tags":["workflow","graphql","apollo"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}