{"record":{"id":"3edc02d3e13e4c47","repo":"medusajs/medusa","slug":"invalid-data-3edc02","errorCode":"invalid_data","errorMessage":"Cannot set price list starts at with with invalid date string: ${priceListData.starts_at}","messagePattern":"Cannot set price list starts at with with invalid date string: (.+?)","errorType":"exception","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/pricing/src/utils/validate-price-list-dates.ts","lineNumber":8,"sourceCode":"import { isDate, MedusaError } from \"@medusajs/framework/utils\"\n\nexport const validatePriceListDates = (priceListData: {\n  starts_at?: Date | string | null\n  ends_at?: Date | string | null\n}) => {\n  if (!!priceListData.starts_at && !isDate(priceListData.starts_at)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `Cannot set price list starts at with with invalid date string: ${priceListData.starts_at}`\n    )\n  }\n\n  if (!!priceListData.ends_at && !isDate(priceListData.ends_at)) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `Cannot set price list ends at with with invalid date string: ${priceListData.ends_at}`\n    )\n  }\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/pricing/src/utils/validate-price-list-dates.ts#L1-L21","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nawait pricingModuleService.createPriceLists([\n  { title: 'Summer', starts_at: '27/08/2024' },\n])\n\n// after\nawait pricingModuleService.createPriceLists([\n  { title: 'Summer', starts_at: '2024-08-27T00:00:00Z' },\n])","handlingStrategy":"type-guard","validationCode":"const toDateOrNull = (v?: string | null) => {\n  if (!v) return null\n  const d = new Date(v)\n  return isNaN(d.getTime()) ? undefined /* reject */ : d.toISOString()\n}\nconst starts_at = toDateOrNull(input.starts_at)\nif (input.starts_at && starts_at === undefined) {\n  throw new Error('Invalid starts_at date')\n}","typeGuard":"const isParseableDate = (v: unknown): v is string | Date =>\n  v instanceof Date || (typeof v === 'string' && !isNaN(new Date(v).getTime()))","tryCatchPattern":"try {\n  await pricingService.createPriceLists([data])\n} catch (e) {\n  if (/invalid date string/.test(e.message)) {\n    // re-prompt user for a valid date\n  }\n  throw e\n}","preventionTips":["Use date pickers emitting ISO strings on the frontend","Validate dates at the API boundary with a schema (zod) before hitting the pricing module"],"tags":["pricing","price-list","date-validation"],"backgroundTag":"invalid-date-format","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}