medusajs/medusa · error · MedusaError

application_method.max_quantity is not allowed to be set for

Error message

application_method.max_quantity is not allowed to be set for allocation (${ApplicationMethodAllocation.ACROSS})

What it means

application_method.max_quantity is not allowed when application_method.allocation is 'across'. ACROSS allocation spreads the value over the whole rule set, so per-item quantity caps are meaningless; presence of max_quantity throws INVALID_DATA.

Source

Thrown at packages/modules/promotion/src/utils/validations/application-method.ts:100

      throw new MedusaError(
        MedusaError.Types.INVALID_DATA,
        `application_method.apply_to_quantity is a required field for Promotion type of ${PromotionType.BUYGET}`
      )
    }

    if (MathBN.lt(maxQuantity!, applyToQuantity!)) {
      throw new MedusaError(
        MedusaError.Types.INVALID_DATA,
        `max_quantity (${maxQuantity}) must be greater than or equal to apply_to_quantity (${applyToQuantity}) for BUYGET promotions.`
      )
    }
  }

  if (
    allocation === ApplicationMethodAllocation.ACROSS &&
    isPresent(maxQuantity)
  ) {
    throw new MedusaError(
      MedusaError.Types.INVALID_DATA,
      `application_method.max_quantity is not allowed to be set for allocation (${ApplicationMethodAllocation.ACROSS})`
    )
  }

  if (!allTargetTypes.includes(targetType)) {
    throw new MedusaError(
      MedusaError.Types.INVALID_DATA,
      `application_method.target_type should be one of ${allTargetTypes.join(
        ", "
      )}`
    )
  }

  const allTypes: string[] = Object.values(ApplicationMethodType)

  if (!allTypes.includes(applicationMethodType)) {
    throw new MedusaError(

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Remove max_quantity from the payload when allocation is 'across'
  2. Conditionally render/require max_quantity only for allocations that need it (e.g., 'each')
  3. Clean seeds that blanket-set max_quantity on every application method

Example fix

// before
application_method: { type: "fixed", value: 10, target_type: "order", allocation: "across", max_quantity: 5 }

// after
application_method: { type: "fixed", value: 10, target_type: "order", allocation: "across" }
Defensive patterns

Strategy: validation

Validate before calling

if (applicationMethod.allocation === "across") {
  delete applicationMethod.max_quantity
}

Type guard

const isAllocationCompatible = (am: { allocation?: string; max_quantity?: number | null }): boolean => am.allocation !== "across" || am.max_quantity == null

Try / catch

try { await createPromotions(...) } catch (e) { if (e.type === MedusaError.Types.INVALID_DATA && /not allowed to be set for allocation/.test(e.message)) { /* strip max_quantity and resubmit */ } throw e }

Prevention

When it happens

Trigger: Creating/updating a promotion with allocation 'across' (typical for order-level or fixed-type application methods) and also supplying max_quantity.

Common situations: Templates for 'each' allocation reused for 'across', admin forms not hiding the max_quantity field when allocation changes, buy-get field sets copied into across-allocated methods.

Related errors


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