medusajs/medusa · error · MedusaError
application_method.allocation should be one of ${allAllocati
Error message
application_method.allocation should be one of ${allAllocationTypes.join(", ")} What it means
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.
Source
Thrown at packages/modules/promotion/src/utils/validations/application-method.ts:143
allowedAllocationTargetTypes.includes(targetType) &&
!allowedAllocationTypes.includes(allocation || "")
) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`application_method.allocation should be either '${allowedAllocationTypes.join(
" OR "
)}' when application_method.target_type is either '${allowedAllocationTargetTypes.join(
" OR "
)}'`
)
}
const allAllocationTypes: string[] = Object.values(
ApplicationMethodAllocation
)
if (allocation && !allAllocationTypes.includes(allocation)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`application_method.allocation should be one of ${allAllocationTypes.join(
", "
)}`
)
}
if (
allocation &&
allowedAllocationForQuantity.includes(allocation) &&
!isDefined(maxQuantity)
) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`application_method.max_quantity is required when application_method.allocation is '${allowedAllocationForQuantity.join(
" OR "
)}'`
)View on GitHub (pinned to 5e06e544a2)
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
Example fix
// before
application_method: { allocation: "per_item", ... }
// after
import { ApplicationMethodAllocation } from "@medusajs/utils"
application_method: { allocation: ApplicationMethodAllocation.EACH, ... } Defensive patterns
Strategy: type-guard
Validate before calling
const allAllocationTypes = Object.values(ApplicationMethodAllocation)
if (allocation && !allAllocationTypes.includes(allocation)) throw new Error(`invalid allocation: ${allocation}`) Type guard
import { ApplicationMethodAllocation } from "@medusajs/utils"
const isValidAllocation = (a: string): a is ApplicationMethodAllocation =>
(Object.values(ApplicationMethodAllocation) as string[]).includes(a) Try / catch
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 } Prevention
- Use exported enum constants
- Normalize/trim imported allocation strings
- Avoid free-text allocation inputs
When it happens
Trigger: Passing allocation 'per_item', 'EVERY', 'all', or a typo like 'across ' with trailing whitespace.
Common situations: Hardcoded strings from older Medusa versions, free-text allocation inputs, data imports with unnormalized 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.max_quantity is not allowed to be set for
- application_method.target_type should be one of ${allTargetT
- application_method.type should be one of ${allTypes.join(",
- application_method.allocation should be either '${allowedAll
- application_method.max_quantity is required when application
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/c22fcbc54efacdd8.
Report an issue: GitHub.