medusajs/medusa · warning · Error

Cannot merge less than two actions

Error message

Cannot merge less than two actions

What it means

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.

Source

Thrown at packages/core/orchestration/src/transaction/orchestrator-builder.ts:257

    return this
  }

  moveAction(actionToMove: string, targetAction: string): OrchestratorBuilder {
    return this.move(actionToMove, targetAction)
  }

  moveAndMergeNextAction(
    actionToMove: string,
    targetAction: string
  ): OrchestratorBuilder {
    return this.move(actionToMove, targetAction, { mergeNext: true })
  }

  mergeActions(where: string, ...actions: string[]) {
    actions.unshift(where)

    if (actions.length < 2) {
      throw new Error("Cannot merge less than two actions")
    }

    for (const action of actions) {
      if (action !== where) {
        this.move(action, where, { runInParallel: true })
      }
    }

    return this
  }

  deleteAction(action: string, steps: InternalStep = this.steps) {
    const actionStep = this.findOrThrowStepByAction(action)
    const parentStep = this.findParentStepByAction(action, steps)!

    if (Array.isArray(parentStep.next)) {
      const index = parentStep.next.findIndex((step) => step.action === action)
      if (index > -1 && actionStep.next) {

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Pass at least two action names: mergeActions('a', 'b', ...)
  2. If building dynamically, guard: if (actions.length >= 2) builder.mergeActions(where, ...actions)

Example fix

// before
builder.mergeActions('createOrder')

// after
builder.mergeActions('createOrder', 'createReservation')
Defensive patterns

Strategy: validation

Validate before calling

if (actions.length >= 2) {
  builder.mergeActions(where, ...actions)
}

Prevention

When it happens

Trigger: 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.

Common situations: Dynamically building the actions list from a variable that ends up empty/single-element; copy-pasted compose code where the second argument was dropped.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/6c4cae9e389c92b7. Report an issue: GitHub.