{"record":{"id":"b8d3051cfb9cb28b","repo":"medusajs/medusa","slug":"application-method-target-type-should-be-one-of","errorCode":null,"errorMessage":"application_method.target_type should be one of ${allTargetTypes.join(\", \")}","messagePattern":"application_method\\.target_type should be one of (.+?)","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/promotion/src/utils/validations/application-method.ts","lineNumber":107,"sourceCode":"      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(\n      MedusaError.Types.INVALID_DATA,\n      `application_method.type should be one of ${allTypes.join(\", \")}`\n    )\n  }\n\n  if (\n    allowedAllocationTargetTypes.includes(targetType) &&","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/promotion/src/utils/validations/application-method.ts#L89-L125","documentation":"application_method.target_type must be one of the allowed ApplicationMethodTargetType values (items, shipping_methods, shipping_method, order, custom...). An unknown value throws INVALID_DATA with the allowed list in the message.","triggerScenarios":"Sending target_type like 'product', 'line_item', 'ITEMS' (wrong case), or a typo such as 'shippingmethoods' in create/updatePromotions.","commonSituations":"Old API payloads from versions with different enum members, case-sensitivity issues, hand-written integrations guessing enum values.","solutions":["Use an exact value from ApplicationMethodTargetType (e.g., 'items', 'shipping_methods', 'order')","Check the enum in @medusajs/framework/utils or the error message's allowed list and correct the payload","Add enum validation in the client form"],"exampleFix":"// before\napplication_method: { target_type: \"product\", ... }\n\n// after\napplication_method: { target_type: \"items\", ... }","handlingStrategy":"type-guard","validationCode":"const allTargetTypes = Object.values(ApplicationMethodTargetType)\nif (!allTargetTypes.includes(targetType)) throw new Error(`invalid target_type: ${targetType}`)","typeGuard":"import { ApplicationMethodTargetType } from \"@medusajs/utils\"\nconst isValidTargetType = (t: string): t is ApplicationMethodTargetType =>\n  (Object.values(ApplicationMethodTargetType) as string[]).includes(t)","tryCatchPattern":"try { await createPromotions(...) } catch (e) { if (e.type === MedusaError.Types.INVALID_DATA && /target_type should be one of/.test(e.message)) { /* read allowed list from message, fix value */ } throw e }","preventionTips":["Use the exported enum, never raw strings","Pin enum usage to your Medusa version","Add enum dropdowns in admin forms"],"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"}