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
- Remove max_quantity from the payload when allocation is 'across'
- Conditionally render/require max_quantity only for allocations that need it (e.g., 'each')
- 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
- Hide max_quantity input when allocation is across
- Clean templates when switching allocation
- Remember across spreads over the whole target set
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
- application_method.allocation should be either '${allowedAll
- application_method.allocation 'once' is not compatible with
- Application Method value should be a percentage number betwe
- application_method.target_type should be one of ${allTargetT
- application_method.type should be one of ${allTypes.join(",
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/ae83d33bebc83bfb.
Report an issue: GitHub.