makeplane/plane · error · Error

Invalid relative amount: ${amountStr}

Error message

Invalid relative amount: ${amountStr}

What it means

Thrown by processRelativeDate when parsing the amount portion of a relative-date token like '1_weeks'. The string is split on '_' and the first segment must parseInt to a valid number; if it is NaN (non-numeric or missing), the token is rejected. The token format is `<integer>_<unit>`.

Source

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

      date: new Date(start).toISOString().split("T")[0],
    });
    // Increment the date by 1 day (86400000 milliseconds)
    start.setDate(start.getDate() + 1);
  }

  return dateArray;
};

/**
 * Processes relative date strings like "1_weeks", "2_months" etc and returns a Date
 * @param value The relative date string (e.g., "1_weeks", "2_months")
 * @returns Date object representing the calculated date
 */
export const processRelativeDate = (value: string): Date => {
  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;

View on GitHub (pinned to 1c8a60f858)

Solutions

  1. Verify the token shape is `<int>_<days|weeks|months>` before calling; route raw user input through parseDateFilter which splits on ';'.
  2. Fix the token producer to always emit an integer amount.
  3. Catch the error at the filter-execution boundary and fall back to ignoring the filter with a user notice.

Example fix

// before
const d = processRelativeDate(rawValue);

// after
const RELATIVE_RE = /^-?\d+_(days|weeks|months)$/;
const d = RELATIVE_RE.test(rawValue)
  ? processRelativeDate(rawValue)
  : (() => { throw new Error(`Bad relative date token: ${rawValue}`); })();
Defensive patterns

Strategy: validation

Validate before calling

const RELATIVE_RE = /^-?\d+_(days|weeks|months)$/;
function isValidRelativeToken(v: string): boolean { return RELATIVE_RE.test(v); }

Type guard

function isRelativeToken(v: string): v is `${number}_${'days'|'weeks'|'months'}` {
  return /^-?\d+_(days|weeks|months)$/.test(v);
}

Try / catch

try { processRelativeDate(v); } catch (e) { if (/Invalid relative amount/.test((e as Error).message)) { /* ignore bad filter */ } else throw e; }

Prevention

When it happens

Trigger: Calling processRelativeDate('abc_weeks'), processRelativeDate('_weeks'), or processRelativeDate('1.5_weeks') (parseFloat would work but parseInt floors — NaN only for non-numeric). Any value whose prefix is not an integer.

Common situations: User-typed or URL-param filter value that did not pass through parseDateFilter; storing a relative token from a different system with a different delimiter; off-by-one in a token builder that omits the amount.

Related errors


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