{"record":{"id":"ae83d33bebc83bfb","repo":"medusajs/medusa","slug":"application-method-max-quantity-is-not-allowed-to","errorCode":null,"errorMessage":"application_method.max_quantity is not allowed to be set for allocation (${ApplicationMethodAllocation.ACROSS})","messagePattern":"application_method\\.max_quantity is not allowed to be set for allocation \\((.+?)\\)","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/promotion/src/utils/validations/application-method.ts","lineNumber":100,"sourceCode":"      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        `application_method.apply_to_quantity is a required field for Promotion type of ${PromotionType.BUYGET}`\n      )\n    }\n\n    if (MathBN.lt(maxQuantity!, applyToQuantity!)) {\n      throw new MedusaError(\n        MedusaError.Types.INVALID_DATA,\n        `max_quantity (${maxQuantity}) must be greater than or equal to apply_to_quantity (${applyToQuantity}) for BUYGET promotions.`\n      )\n    }\n  }\n\n  if (\n    allocation === ApplicationMethodAllocation.ACROSS &&\n    isPresent(maxQuantity)\n  ) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `application_method.max_quantity is not allowed to be set for allocation (${ApplicationMethodAllocation.ACROSS})`\n    )\n  }\n\n  if (!allTargetTypes.includes(targetType)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `application_method.target_type should be one of ${allTargetTypes.join(\n        \", \"\n      )}`\n    )\n  }\n\n  const allTypes: string[] = Object.values(ApplicationMethodType)\n\n  if (!allTypes.includes(applicationMethodType)) {\n    throw new MedusaError(","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/promotion/src/utils/validations/application-method.ts#L82-L118","documentation":"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.","triggerScenarios":"Creating/updating a promotion with allocation 'across' (typical for order-level or fixed-type application methods) and also supplying max_quantity.","commonSituations":"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.","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"],"exampleFix":"// before\napplication_method: { type: \"fixed\", value: 10, target_type: \"order\", allocation: \"across\", max_quantity: 5 }\n\n// after\napplication_method: { type: \"fixed\", value: 10, target_type: \"order\", allocation: \"across\" }","handlingStrategy":"validation","validationCode":"if (applicationMethod.allocation === \"across\") {\n  delete applicationMethod.max_quantity\n}","typeGuard":"const isAllocationCompatible = (am: { allocation?: string; max_quantity?: number | null }): boolean => am.allocation !== \"across\" || am.max_quantity == null","tryCatchPattern":"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 }","preventionTips":["Hide max_quantity input when allocation is across","Clean templates when switching allocation","Remember across spreads over the whole target set"],"tags":["promotion","application-method","allocation","validation","medusa"],"backgroundTag":"mutually-exclusive-fields","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}