makeplane/plane · error · Error

Unsupported time unit: ${unit}

Error message

Unsupported time unit: ${unit}

What it means

Thrown by the default branch of processRelativeDate's switch on the unit segment. Only 'days', 'weeks', and 'months' are implemented; any other unit string (years, hours, quarters, typos) hits default and raises this. The unit comes from the second half of the `<amount>_<unit>` token.

Source

Thrown at packages/utils/src/datetime.ts:439

  const [amountStr, unit] = value.split("_");
  const amount = parseInt(amountStr, 10);
  if (isNaN(amount)) {
    throw new Error(`Invalid relative amount: ${amountStr}`);
  }
  const date = new Date();

  switch (unit) {
    case "days":
      date.setDate(date.getDate() + amount);
      break;
    case "weeks":
      date.setDate(date.getDate() + amount * 7);
      break;
    case "months":
      date.setMonth(date.getMonth() + amount);
      break;
    default:
      throw new Error(`Unsupported time unit: ${unit}`);
  }

  return date;
};

/**
 * Parses a date filter string and returns the comparison type and date
 * @param filterValue The date filter string (e.g., "1_weeks;after;fromnow" or "2024-12-01;after")
 * @returns Object containing the comparison type and target date
 */
export const parseDateFilter = (filterValue: string): { type: "after" | "before"; date: Date } => {
  const parts = filterValue.split(";");
  const dateStr = parts[0];
  const type = parts[1] as "after" | "before";

  let date: Date;
  if (dateStr.includes("_")) {
    // Handle relative dates (e.g., "1_weeks;after;fromnow")

View on GitHub (pinned to 1c8a60f858)

Solutions

  1. Map unsupported units to supported ones before calling (years -> 12 months, quarters -> 3 months).
  2. Extend the switch to handle the additional unit if it should be first-class.
  3. Validate the unit against an allowlist before invoking processRelativeDate.

Example fix

// before
processRelativeDate(`${n}_years`)

// after
processRelativeDate(`${n * 12}_months`)
Defensive patterns

Strategy: validation

Validate before calling

const UNITS = ['days','weeks','months'] as const;
function supportedUnit(u: string): boolean { return (UNITS as readonly string[]).includes(u); }

Type guard

type Unit = typeof UNITS[number];
function isUnit(u: string): u is Unit { return (UNITS as readonly string[]).includes(u); }

Try / catch

try { processRelativeDate(v); } catch (e) { if (/Unsupported time unit/.test((e as Error).message)) { /* map or skip */ } else throw e; }

Prevention

When it happens

Trigger: processRelativeDate('1_years'), processRelativeDate('2_week'), processRelativeDate('3_hrs') — anything whose unit is not exactly 'days'/'weeks'/'months'.

Common situations: Token producer uses a different vocabulary (years, quarters); typo in a hand-authored token; mismatch between the UI labels and the supported unit strings.

Related errors


AI-assisted analysis of makeplane/plane@1c8a60f858 (2026-08-12). Data as JSON: /api/errors/cf73326fce6fddb9. Report an issue: GitHub.