From 564c511163664753a181078b3e81401a730e8a1c Mon Sep 17 00:00:00 2001 From: Sebastien La Duca Date: Fri, 27 Mar 2026 09:54:55 -0700 Subject: [PATCH 1/2] fix: validate --start flag input and error on unparseable values Previously, passing an invalid string to -s/--start (e.g. a typo or free-form text) would silently fall back to NOW via chrono-node's parseDate returning null. The command would then proceed as if no start time was specified. Now the argParser throws a CommanderError with a clear message when the input cannot be parsed as a date. Co-Authored-By: Claude Sonnet 4.6 --- src/lib/nodes/utils.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/nodes/utils.ts b/src/lib/nodes/utils.ts index f9b16ae..4215786 100644 --- a/src/lib/nodes/utils.ts +++ b/src/lib/nodes/utils.ts @@ -9,7 +9,6 @@ import utc from "dayjs/plugin/utc.js"; import { parseDurationArgument } from "../../helpers/duration.ts"; import { logAndQuit } from "../../helpers/errors.ts"; import { formatNullableDateRange } from "../../helpers/format-time.ts"; -import { parseStartDateOrNow } from "../../helpers/units.ts"; dayjs.extend(utc); dayjs.extend(timezone); @@ -330,11 +329,25 @@ export const maxPriceOption = new Option( /** * Common --start option using same parser as buy command */ +function parseStartDateOrNowOrThrow(val: string): Date | "NOW" { + const nowRe = /\b(?:"|')?[nN][oO][wW](?:"|')?\b/; + if (nowRe.test(val)) return "NOW"; + const chronoDate = parseDate(val); + if (!chronoDate) { + throw new CommanderError( + 1, + "INVALID_START", + `Invalid start time: "${val}". Use ISO 8601 format (e.g. '2024-01-15T10:00:00Z'), a relative time (e.g. '+1h'), or 'NOW'.`, + ); + } + return chronoDate; +} + export const startOrNowOption = new Option( "-s, --start ", "Start time (ISO 8601 format:'2022-10-27T14:30:00Z' or relative time like '+1d', or 'NOW')", ) - .argParser(parseStartDateOrNow) + .argParser(parseStartDateOrNowOrThrow) .default("NOW" as const); /** From 39775c29b3a1ecddae9fbb549add067a30f5eb97 Mon Sep 17 00:00:00 2001 From: Sebastien La Duca Date: Fri, 27 Mar 2026 10:19:27 -0700 Subject: [PATCH 2/2] fix error message --- src/lib/nodes/utils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/nodes/utils.ts b/src/lib/nodes/utils.ts index 4215786..a9c32e3 100644 --- a/src/lib/nodes/utils.ts +++ b/src/lib/nodes/utils.ts @@ -334,9 +334,7 @@ function parseStartDateOrNowOrThrow(val: string): Date | "NOW" { if (nowRe.test(val)) return "NOW"; const chronoDate = parseDate(val); if (!chronoDate) { - throw new CommanderError( - 1, - "INVALID_START", + logAndQuit( `Invalid start time: "${val}". Use ISO 8601 format (e.g. '2024-01-15T10:00:00Z'), a relative time (e.g. '+1h'), or 'NOW'.`, ); }