medusajs/medusa · error · MedusaError
invalid_data
invalid_data
Error message
Cannot set price list starts at with with invalid date string: ${priceListData.starts_at} What it means
validatePriceListDates checks that a price list's starts_at (and ends_at) values, when provided, are valid dates (Date instances or parseable date strings per isDate). An unparseable starts_at string throws INVALID_DATA.
Source
Thrown at packages/modules/pricing/src/utils/validate-price-list-dates.ts:8
import { isDate, MedusaError } from "@medusajs/framework/utils"
export const validatePriceListDates = (priceListData: {
starts_at?: Date | string | null
ends_at?: Date | string | null
}) => {
if (!!priceListData.starts_at && !isDate(priceListData.starts_at)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Cannot set price list starts at with with invalid date string: ${priceListData.starts_at}`
)
}
if (!!priceListData.ends_at && !isDate(priceListData.ends_at)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Cannot set price list ends at with with invalid date string: ${priceListData.ends_at}`
)
}
}
View on GitHub (pinned to 5e06e544a2)
Solutions
- Pass ISO 8601 strings ('2024-08-27T00:00:00Z') or Date objects
- Normalize/validate user-supplied date input before calling create/updatePriceList
- Use null to clear a date rather than an empty or garbage string
Example fix
// before
await pricingModuleService.createPriceLists([
{ title: 'Summer', starts_at: '27/08/2024' },
])
// after
await pricingModuleService.createPriceLists([
{ title: 'Summer', starts_at: '2024-08-27T00:00:00Z' },
]) Defensive patterns
Strategy: type-guard
Validate before calling
const toDateOrNull = (v?: string | null) => {
if (!v) return null
const d = new Date(v)
return isNaN(d.getTime()) ? undefined /* reject */ : d.toISOString()
}
const starts_at = toDateOrNull(input.starts_at)
if (input.starts_at && starts_at === undefined) {
throw new Error('Invalid starts_at date')
} Type guard
const isParseableDate = (v: unknown): v is string | Date => v instanceof Date || (typeof v === 'string' && !isNaN(new Date(v).getTime()))
Try / catch
try {
await pricingService.createPriceLists([data])
} catch (e) {
if (/invalid date string/.test(e.message)) {
// re-prompt user for a valid date
}
throw e
} Prevention
- Use date pickers emitting ISO strings on the frontend
- Validate dates at the API boundary with a schema (zod) before hitting the pricing module
When it happens
Trigger: Creating/updating a price list with starts_at set to a malformed string like '2024-13-45' or 'tomorrow-ish', or a non-date truthy value.
Common situations: Dates coming raw from user form input or query params without validation, empty-string vs null confusion, or locale-format date strings that don't parse.
Related errors
- invalid_data
- Variants with IDs ${priceNotFound.join(", ")} do not have a
- Line item ${item.title} has no unit price
- Missing required pricing context to calculate prices - regio
- Region with id ${req.filterableFields.region_id} not found w
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/3edc02d3e13e4c47.
Report an issue: GitHub.