medusajs/medusa · error · MedusaError
application_method.target_type should be one of ${allTargetT
Error message
application_method.target_type should be one of ${allTargetTypes.join(", ")} What it means
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.
Source
Thrown at packages/modules/promotion/src/utils/validations/application-method.ts:107
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`max_quantity (${maxQuantity}) must be greater than or equal to apply_to_quantity (${applyToQuantity}) for BUYGET promotions.`
)
}
}
if (
allocation === ApplicationMethodAllocation.ACROSS &&
isPresent(maxQuantity)
) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`application_method.max_quantity is not allowed to be set for allocation (${ApplicationMethodAllocation.ACROSS})`
)
}
if (!allTargetTypes.includes(targetType)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`application_method.target_type should be one of ${allTargetTypes.join(
", "
)}`
)
}
const allTypes: string[] = Object.values(ApplicationMethodType)
if (!allTypes.includes(applicationMethodType)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`application_method.type should be one of ${allTypes.join(", ")}`
)
}
if (
allowedAllocationTargetTypes.includes(targetType) &&View on GitHub (pinned to 5e06e544a2)
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
Example fix
// before
application_method: { target_type: "product", ... }
// after
application_method: { target_type: "items", ... } Defensive patterns
Strategy: type-guard
Validate before calling
const allTargetTypes = Object.values(ApplicationMethodTargetType)
if (!allTargetTypes.includes(targetType)) throw new Error(`invalid target_type: ${targetType}`) Type guard
import { ApplicationMethodTargetType } from "@medusajs/utils"
const isValidTargetType = (t: string): t is ApplicationMethodTargetType =>
(Object.values(ApplicationMethodTargetType) as string[]).includes(t) Try / catch
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 } Prevention
- Use the exported enum, never raw strings
- Pin enum usage to your Medusa version
- Add enum dropdowns in admin forms
When it happens
Trigger: Sending target_type like 'product', 'line_item', 'ITEMS' (wrong case), or a typo such as 'shippingmethoods' in create/updatePromotions.
Common situations: Old API payloads from versions with different enum members, case-sensitivity issues, hand-written integrations guessing enum values.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- application_method.type should be one of ${allTypes.join(",
- Application Method value should be a percentage number betwe
- application_method.max_quantity is not allowed to be set for
- application_method.allocation should be either '${allowedAll
- application_method.allocation should be one of ${allAllocati
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/b8d3051cfb9cb28b.
Report an issue: GitHub.