{"record":{"id":"6c4cae9e389c92b7","repo":"medusajs/medusa","slug":"cannot-merge-less-than-two-actions","errorCode":null,"errorMessage":"Cannot merge less than two actions","messagePattern":"Cannot merge less than two actions","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/core/orchestration/src/transaction/orchestrator-builder.ts","lineNumber":257,"sourceCode":"    return this\n  }\n\n  moveAction(actionToMove: string, targetAction: string): OrchestratorBuilder {\n    return this.move(actionToMove, targetAction)\n  }\n\n  moveAndMergeNextAction(\n    actionToMove: string,\n    targetAction: string\n  ): OrchestratorBuilder {\n    return this.move(actionToMove, targetAction, { mergeNext: true })\n  }\n\n  mergeActions(where: string, ...actions: string[]) {\n    actions.unshift(where)\n\n    if (actions.length < 2) {\n      throw new Error(\"Cannot merge less than two actions\")\n    }\n\n    for (const action of actions) {\n      if (action !== where) {\n        this.move(action, where, { runInParallel: true })\n      }\n    }\n\n    return this\n  }\n\n  deleteAction(action: string, steps: InternalStep = this.steps) {\n    const actionStep = this.findOrThrowStepByAction(action)\n    const parentStep = this.findParentStepByAction(action, steps)!\n\n    if (Array.isArray(parentStep.next)) {\n      const index = parentStep.next.findIndex((step) => step.action === action)\n      if (index > -1 && actionStep.next) {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/orchestration/src/transaction/orchestrator-builder.ts#L239-L275","documentation":"mergeActions(where, ...actions) merges several steps into one parallel group by first unshifting where into the list, so fewer than 2 total arguments means there is nothing to merge and indicates a programming mistake. The builder rejects this immediately.","triggerScenarios":"Calling mergeActions with only one action name (or none), e.g. mergeActions('a') — after unshift the list has length 1. Only reachable via direct builder use since TS typing for rest args discourages it.","commonSituations":"Dynamically building the actions list from a variable that ends up empty/single-element; copy-pasted compose code where the second argument was dropped.","solutions":["Pass at least two action names: mergeActions('a', 'b', ...)","If building dynamically, guard: if (actions.length >= 2) builder.mergeActions(where, ...actions)"],"exampleFix":"// before\nbuilder.mergeActions('createOrder')\n\n// after\nbuilder.mergeActions('createOrder', 'createReservation')","handlingStrategy":"validation","validationCode":"if (actions.length >= 2) {\n  builder.mergeActions(where, ...actions)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When merging dynamically-computed action lists, assert length >= 2 first"],"tags":["orchestration","workflow-graph","builder","invalid-arguments"],"backgroundTag":"invalid-workflow-composition","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}