{"record":{"id":"c22fcbc54efacdd8","repo":"medusajs/medusa","slug":"application-method-allocation-should-be-one-of-a","errorCode":null,"errorMessage":"application_method.allocation should be one of ${allAllocationTypes.join(\", \")}","messagePattern":"application_method\\.allocation should be one of (.+?)","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/promotion/src/utils/validations/application-method.ts","lineNumber":143,"sourceCode":"    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        \", \"\n      )}`\n    )\n  }\n\n  if (\n    allocation &&\n    allowedAllocationForQuantity.includes(allocation) &&\n    !isDefined(maxQuantity)\n  ) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `application_method.max_quantity is required when application_method.allocation is '${allowedAllocationForQuantity.join(\n        \" OR \"\n      )}'`\n    )","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/promotion/src/utils/validations/application-method.ts#L125-L161","documentation":"If application_method.allocation is provided, it must be one of the ApplicationMethodAllocation enum values (each, across, once per version). Any other string throws INVALID_DATA.","triggerScenarios":"Passing allocation 'per_item', 'EVERY', 'all', or a typo like 'across ' with trailing whitespace.","commonSituations":"Hardcoded strings from older Medusa versions, free-text allocation inputs, data imports with unnormalized values.","solutions":["Use the enum constant: ApplicationMethodAllocation.EACH / ACROSS / ONCE","Import the enum from @medusajs/utils instead of hardcoding strings","Trim/normalize imported values and validate against the enum before submission"],"exampleFix":"// before\napplication_method: { allocation: \"per_item\", ... }\n\n// after\nimport { ApplicationMethodAllocation } from \"@medusajs/utils\"\napplication_method: { allocation: ApplicationMethodAllocation.EACH, ... }","handlingStrategy":"type-guard","validationCode":"const allAllocationTypes = Object.values(ApplicationMethodAllocation)\nif (allocation && !allAllocationTypes.includes(allocation)) throw new Error(`invalid allocation: ${allocation}`)","typeGuard":"import { ApplicationMethodAllocation } from \"@medusajs/utils\"\nconst isValidAllocation = (a: string): a is ApplicationMethodAllocation =>\n  (Object.values(ApplicationMethodAllocation) as string[]).includes(a)","tryCatchPattern":"try { await updatePromotions(...) } catch (e) { if (e.type === MedusaError.Types.INVALID_DATA && /allocation should be one of/.test(e.message)) { /* normalize allocation to enum and retry */ } throw e }","preventionTips":["Use exported enum constants","Normalize/trim imported allocation strings","Avoid free-text allocation inputs"],"tags":["promotion","application-method","allocation","enum","medusa"],"backgroundTag":"invalid-enum-value","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}