{"record":{"id":"304f0d188345dd9f","repo":"hcengineering/platform","slug":"unsupported-time-unit-unit","errorCode":null,"errorMessage":"Unsupported time unit: ${unit}","messagePattern":"Unsupported time unit: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/card-resources/src/components/navigator-next/NavigatorCardsSection.svelte","lineNumber":69,"sourceCode":"  function parseLookbackDuration (input: string): Timestamp {\n    if (input.length < 2) throw new Error('Invalid duration format')\n\n    const unit = input.slice(-1)\n    const numberPart = input.slice(0, -1)\n    const value = Number(numberPart)\n\n    if (isNaN(value) || value <= 0) throw new Error('Invalid numeric value')\n\n    const multipliers: Record<string, number> = {\n      m: 60 * 1000,\n      h: 60 * 60 * 1000,\n      d: 24 * 60 * 60 * 1000,\n      w: 7 * 24 * 60 * 60 * 1000\n    }\n\n    const multiplier = multipliers[unit]\n\n    if (!multiplier) throw new Error(`Unsupported time unit: ${unit}`)\n\n    return value * multiplier\n  }\n\n  $: cardIds = ids?.filter((it) => !favorites.some((fav) => fav.attachedTo === it))\n\n  $: if ((cardIds && cardIds.length > 0) || (config.labelFilter?.length ?? 0) === 0) {\n    cardsQuery.query<Card>(\n      type._id,\n      {\n        // TODO: Should be join instead of $in. But for now labels and cards in different api.\n        ...(cardIds === undefined ? {} : { _id: { $in: cardIds } }),\n        ...(space !== undefined ? { space: space._id } : {}),\n        ...(config.lookback !== undefined\n          ? { modifiedOn: { $gte: Date.now() - parseLookbackDuration(config.lookback) } }\n          : {})\n      },\n      (res) => {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/card-resources/src/components/navigator-next/NavigatorCardsSection.svelte#L51-L87","documentation":"After parsing the number, parseLookbackDuration looks up the final character in the multipliers map (m, h, d, w). If the unit character is not one of these, the multiplier is undefined and 'Unsupported time unit: <unit>' is thrown. The parser only supports minutes, hours, days, and weeks.","triggerScenarios":"Passing durations like \"7y\", \"30s\", \"2M\" (case-sensitive), or \"12months\" — the last character is not m/h/d/w.","commonSituations":"Users typing natural units (seconds, months, years) the parser doesn't support, or uppercase units where the map keys are lowercase.","solutions":["Use a supported unit suffix: m (minutes), h (hours), d (days), w (weeks), e.g. \"2w\" instead of \"1month\".","Lowercase/normalize the input before lookup if you want case-insensitive units.","Extend the multipliers map if support for new units (e.g. s, y) is genuinely needed."],"exampleFix":"// before\nconst multiplier = multipliers[unit]\n// after\nconst multiplier = multipliers[unit.toLowerCase()]\nif (!multiplier) throw new Error(`Unsupported time unit: ${unit}`)","handlingStrategy":"validation","validationCode":"const unit = input.slice(-1).toLowerCase()\nif (!['m', 'h', 'd', 'w'].includes(unit)) { ui.notify(`Unsupported unit \"${unit}\"; use m, h, d or w`); return }","typeGuard":"function isSupportedUnit(u: string): u is 'm'|'h'|'d'|'w' { return ['m','h','d','w'].includes(u) }","tryCatchPattern":"try {\n  const ts = parseLookbackDuration(input)\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unsupported time unit')) {\n    input = input.slice(0, -1) + 'd' // or prompt user to fix\n  } else throw e\n}","preventionTips":["Document the supported units (m/h/d/w) wherever the duration field is exposed.","Normalize the unit to lowercase before lookup.","Use a unit dropdown rather than free-text to eliminate unsupported units."],"tags":["validation","parsing","configuration"],"backgroundTag":"unsupported-time-unit","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}