{"record":{"id":"1f8d7d61c49de82f","repo":"medusajs/medusa","slug":"application-method-type-should-be-one-of-alltype","errorCode":null,"errorMessage":"application_method.type should be one of ${allTypes.join(\", \")}","messagePattern":"application_method\\.type should be one of (.+?)","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/promotion/src/utils/validations/application-method.ts","lineNumber":118,"sourceCode":"    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(\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  }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/promotion/src/utils/validations/application-method.ts#L100-L136","documentation":"application_method.type must be one of the ApplicationMethodType values (fixed, percentage, buyget... per the installed version). Any other string throws INVALID_DATA listing the valid types.","triggerScenarios":"Passing application_method.type 'flat', 'percent', 'absolute', or an outdated value no longer in the enum.","commonSituations":"Version upgrades that renamed/removed enum members, integrations written from memory instead of the types package, case mistakes ('Percentage').","solutions":["Set type to a valid ApplicationMethodType ('fixed', 'percentage', 'buyget' as available)","After upgrading Medusa, re-check the enum — re-export or inline the constants from @medusajs/utils rather than hardcoding strings","Add a zod/enum check in the API layer"],"exampleFix":"// before\napplication_method: { type: \"percent\", value: 10, ... }\n\n// after\nimport { ApplicationMethodType } from \"@medusajs/utils\"\napplication_method: { type: ApplicationMethodType.PERCENTAGE, value: 10, ... }","handlingStrategy":"type-guard","validationCode":"const allTypes = Object.values(ApplicationMethodType)\nif (!allTypes.includes(am.type)) throw new Error(`invalid application_method.type: ${am.type}`)","typeGuard":"import { ApplicationMethodType } from \"@medusajs/utils\"\nconst isValidApplicationMethodType = (t: string): t is ApplicationMethodType =>\n  (Object.values(ApplicationMethodType) as string[]).includes(t)","tryCatchPattern":"try { await createPromotions(...) } catch (e) { if (e.type === MedusaError.Types.INVALID_DATA && /application_method.type should be one of/.test(e.message)) { /* map legacy value to current enum and retry */ } throw e }","preventionTips":["Import enums from the package instead of hardcoding","Recheck enums after Medusa upgrades","Add zod enum validation at the API boundary"],"tags":["promotion","application-method","enum","validation","medusa"],"backgroundTag":"invalid-enum-value","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}