{"record":{"id":"83986f8ad12cbce2","repo":"medusajs/medusa","slug":"application-method-allocation-should-be-either","errorCode":null,"errorMessage":"application_method.allocation should be either '${allowedAllocationTypes.join(\" OR \")}' when application_method.target_type is either '${allowedAllocationTargetTypes.join(\" OR \")}'","messagePattern":"application_method\\.allocation should be either '(.+?)' when application_method\\.target_type is either '(.+?)'","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/promotion/src/utils/validations/application-method.ts","lineNumber":128,"sourceCode":"        \", \"\n      )}`\n    )\n  }\n\n  const allTypes: string[] = Object.values(ApplicationMethodType)\n\n  if (!allTypes.includes(applicationMethodType)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `application_method.type should be one of ${allTypes.join(\", \")}`\n    )\n  }\n\n  if (\n    allowedAllocationTargetTypes.includes(targetType) &&\n    !allowedAllocationTypes.includes(allocation || \"\")\n  ) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `application_method.allocation should be either '${allowedAllocationTypes.join(\n        \" OR \"\n      )}' when application_method.target_type is either '${allowedAllocationTargetTypes.join(\n        \" OR \"\n      )}'`\n    )\n  }\n\n  const allAllocationTypes: string[] = Object.values(\n    ApplicationMethodAllocation\n  )\n\n  if (allocation && !allAllocationTypes.includes(allocation)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `application_method.allocation should be one of ${allAllocationTypes.join(\n        \", \"","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/promotion/src/utils/validations/application-method.ts#L110-L146","documentation":"When application_method.target_type is one of the item-level target types (items / shipping_methods), allocation must be 'each' or 'across' (the allowedAllocationTypes). Any other (or missing) allocation for those target types throws INVALID_DATA.","triggerScenarios":"Creating a promotion with target_type 'items' but omitting allocation, or setting allocation 'once'/'' alongside target_type 'items' or 'shipping_methods'.","commonSituations":"Assuming allocation is optional, forms with a default of 'once' applied to item-level promos, porting order-level payloads to item-level target types.","solutions":["Set allocation to 'each' (per-item) or 'across' (spread) whenever target_type is items/shipping_methods","Use 'each' for percentage/fixed per-item discounts and 'across' for spread fixed amounts","Make allocation required in the form when an item-level target type is chosen"],"exampleFix":"// before\napplication_method: { type: \"percentage\", value: 10, target_type: \"items\" }\n\n// after\napplication_method: { type: \"percentage\", value: 10, target_type: \"items\", allocation: \"each\" }","handlingStrategy":"validation","validationCode":"const allowedAllocationTypes = [ApplicationMethodAllocation.EACH, ApplicationMethodAllocation.ACROSS]\nif ([\"items\", \"shipping_methods\"].includes(targetType) && !allowedAllocationTypes.includes(allocation)) {\n  allocation = ApplicationMethodAllocation.EACH\n}","typeGuard":"const isItemLevelAllocationValid = (targetType: string, allocation?: string): boolean => ![\"items\", \"shipping_methods\"].includes(targetType) || !!allocation && [\"each\", \"across\"].includes(allocation)","tryCatchPattern":"try { await createPromotions(...) } catch (e) { if (e.type === MedusaError.Types.INVALID_DATA && /allocation should be either/.test(e.message)) { /* set allocation each/across and resubmit */ } throw e }","preventionTips":["Make allocation required for item-level target types","Default item-level discounts to 'each'","Test payloads per target_type"],"tags":["promotion","application-method","allocation","validation","medusa"],"backgroundTag":"missing-required-field","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}