jackwener/OpenCLI · error · ArgumentError
Date must be YYYY-MM-DD: ${date}
Error message
Date must be YYYY-MM-DD: ${date} What it means
parseDate requires the date in strict YYYY-MM-DD form via regex ^\d{4}-\d{2}-\d{2}$. Any other format — slashes, missing zero-padding, extra whitespace, timestamps — throws this ArgumentError before the real-calendar check runs.
Source
Thrown at clis/mercury/utils.js:69
if (!/^\d+(\.\d{1,2})?$/.test(amount) || Number(amount) <= 0) {
throw new ArgumentError(`Amount must be a positive number with up to two decimals: ${amount}`);
}
return amount;
}
function parseCurrency(kwargs) {
const currency = optionalString(kwargs, 'currency', 'CNY').toUpperCase();
if (!/^[A-Z]{3}$/.test(currency)) {
throw new ArgumentError(`Currency must be a three-letter ISO currency code: ${currency}`);
}
return currency;
}
function parseDate(kwargs) {
const date = requireString(kwargs, 'date');
const match = date.match(/^(\d{4})-(\d{2})-(\d{2})$/);
if (!match) {
throw new ArgumentError(`Date must be YYYY-MM-DD: ${date}`);
}
const year = Number(match[1]);
const month = Number(match[2]);
const day = Number(match[3]);
const parsed = new Date(Date.UTC(year, month - 1, day));
if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== day) {
throw new ArgumentError(`Date must be a real calendar date: ${date}`);
}
return date;
}
function parseOcrWaitSeconds(kwargs) {
const raw = optionalString(kwargs, 'ocr-wait-seconds', '8');
if (!/^\d+$/.test(raw)) {
throw new ArgumentError(`ocr-wait-seconds must be a non-negative integer: ${raw}`);
}
return Number(raw);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Format the date as YYYY-MM-DD with zero-padded month and day: 2026-08-01.
- If you have a Date object, use date.toISOString().slice(0, 10).
- Trim the value and strip any time component before passing.
- Normalize MM/DD/YYYY or DD/MM/YYYY inputs by reordering parts before invoking.
Example fix
// before --date "08/01/2026" // after --date "2026-08-01"
Defensive patterns
Strategy: validation
Validate before calling
function isIsoDateShape(d) {
return /^\d{4}-\d{2}-\d{2}$/.test(String(d).trim());
}
// from a Date object:
const iso = new Date().toISOString().slice(0, 10); Try / catch
try {
await reimburse({ date });
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('Date must be YYYY-MM-DD')) {
console.error(`Got '${date}'. Use zero-padded YYYY-MM-DD, e.g. 2026-08-01`);
} else throw e;
} Prevention
- Generate dates with toISOString().slice(0,10)
- Never pass locale-formatted (MM/DD/YYYY) strings directly
- Trim user input before forwarding
- Keep dates as ISO strings end-to-end in scripts
When it happens
Trigger: dates like '2026/08/01', '2026-8-1', '01-08-2026', '2026-08-01T00:00:00Z', '2026-8-01' or values with leading/trailing spaces.
Common situations: Locale-formatted dates pasted from spreadsheets (MM/DD/YYYY); programmatic callers passing ISO datetime strings; shell interpolation inserting whitespace; users from slash-date locales.
Related errors
- ${label} must be a non-negative integer, got ${JSON.stringif
- limit must be a positive integer
- bilibili comment ${label} must be a positive integer
- bilibili comment message cannot be empty
- bilibili unfollow target cannot be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b8c68ace60835085.
Report an issue: GitHub.