hcengineering/platform · error
Unsupported time unit: ${unit}
Error message
Unsupported time unit: ${unit} What it means
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.
Source
Thrown at plugins/card-resources/src/components/navigator-next/NavigatorCardsSection.svelte:69
function parseLookbackDuration (input: string): Timestamp {
if (input.length < 2) throw new Error('Invalid duration format')
const unit = input.slice(-1)
const numberPart = input.slice(0, -1)
const value = Number(numberPart)
if (isNaN(value) || value <= 0) throw new Error('Invalid numeric value')
const multipliers: Record<string, number> = {
m: 60 * 1000,
h: 60 * 60 * 1000,
d: 24 * 60 * 60 * 1000,
w: 7 * 24 * 60 * 60 * 1000
}
const multiplier = multipliers[unit]
if (!multiplier) throw new Error(`Unsupported time unit: ${unit}`)
return value * multiplier
}
$: cardIds = ids?.filter((it) => !favorites.some((fav) => fav.attachedTo === it))
$: if ((cardIds && cardIds.length > 0) || (config.labelFilter?.length ?? 0) === 0) {
cardsQuery.query<Card>(
type._id,
{
// TODO: Should be join instead of $in. But for now labels and cards in different api.
...(cardIds === undefined ? {} : { _id: { $in: cardIds } }),
...(space !== undefined ? { space: space._id } : {}),
...(config.lookback !== undefined
? { modifiedOn: { $gte: Date.now() - parseLookbackDuration(config.lookback) } }
: {})
},
(res) => {View on GitHub (pinned to 63e28dc964)
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.
Example fix
// before
const multiplier = multipliers[unit]
// after
const multiplier = multipliers[unit.toLowerCase()]
if (!multiplier) throw new Error(`Unsupported time unit: ${unit}`) Defensive patterns
Strategy: validation
Validate before calling
const unit = input.slice(-1).toLowerCase()
if (!['m', 'h', 'd', 'w'].includes(unit)) { ui.notify(`Unsupported unit "${unit}"; use m, h, d or w`); return } Type guard
function isSupportedUnit(u: string): u is 'm'|'h'|'d'|'w' { return ['m','h','d','w'].includes(u) } Try / catch
try {
const ts = parseLookbackDuration(input)
} catch (e) {
if (e instanceof Error && e.message.startsWith('Unsupported time unit')) {
input = input.slice(0, -1) + 'd' // or prompt user to fix
} else throw e
} Prevention
- 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.
When it happens
Trigger: Passing durations like "7y", "30s", "2M" (case-sensitive), or "12months" — the last character is not m/h/d/w.
Common situations: Users typing natural units (seconds, months, years) the parser doesn't support, or uppercase units where the map keys are lowercase.
Related errors
- Invalid duration format
- Invalid numeric value
- No screen access granted
- Accounts url not specified
- Ticks per second has an invalid value: must be >= 1 && <= 10
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/304f0d188345dd9f.
Report an issue: GitHub.