{"record":{"id":"5c26ac8afab28909","repo":"jackwener/OpenCLI","slug":"name-has-invalid-month-day-value-5c26ac","errorCode":null,"errorMessage":"--${name} has invalid month/day: ${value}","messagePattern":"--(.+?) has invalid month/day: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/trip/utils.js","lineNumber":41,"sourceCode":"        throw new ArgumentError(`--${name} must be a 3-letter IATA code, got ${JSON.stringify(raw)}`);\n    }\n    return value;\n}\n\nexport function parseIsoDate(name, raw) {\n    if (raw === undefined || raw === null || raw === '') {\n        throw new ArgumentError(`--${name} is required (YYYY-MM-DD)`);\n    }\n    const value = String(raw).trim();\n    const m = ISO_DATE_RE.exec(value);\n    if (!m) {\n        throw new ArgumentError(`--${name} must be YYYY-MM-DD, got ${JSON.stringify(raw)}`);\n    }\n    const year = Number(m[1]);\n    const month = Number(m[2]);\n    const day = Number(m[3]);\n    if (month < 1 || month > 12 || day < 1 || day > 31) {\n        throw new ArgumentError(`--${name} has invalid month/day: ${value}`);\n    }\n    // Cross-check via UTC date math so 2026-02-30 doesn't pass.\n    const parsed = new Date(Date.UTC(year, month - 1, day));\n    if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== day) {\n        throw new ArgumentError(`--${name} is not a real calendar date: ${value}`);\n    }\n    return value;\n}\n\nexport function parseListLimit(raw, fallback = 20) {\n    if (raw === undefined || raw === null || raw === '') return fallback;\n    const parsed = Number(raw);\n    if (!Number.isFinite(parsed) || !Number.isInteger(parsed)) {\n        throw new ArgumentError(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${JSON.stringify(raw)}`);\n    }\n    if (parsed < MIN_LIMIT || parsed > MAX_LIMIT) {\n        throw new ArgumentError(`--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${parsed}`);\n    }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/utils.js#L23-L59","documentation":"After the regex matches, parseIsoDate range-checks the numeric month and day. This error is thrown when month is not 1-12 or day is not 1-31 — structurally plausible-looking digits that are still out of range. It fires before the full calendar check.","triggerScenarios":"Passing e.g. --depart 2026-13-01 (month 13), --date 2026-00-10 (month 0), --checkin 2026-05-32 (day 32), or --date 0000-01-00.","commonSituations":"Typos swapping month/day fields (e.g. 2026-31-05 meaning May 31); hand-typed dates; data imports with offset or malformed date columns; confusion between MM-DD and DD-MM orders.","solutions":["Correct the month to 01-12 and the day to 01-31","Check whether month and day were swapped (e.g. 2026-31-05 likely means 2026-05-31)","Validate dates programmatically before passing them (e.g. with a date library or regex plus range check)","If the source is data with ambiguous formats, normalize it to ISO YYYY-MM-DD first"],"exampleFix":"// before\nclis-trip flights --depart 2026-13-01\n// after\nclis-trip flights --depart 2026-12-01","handlingStrategy":"validation","validationCode":"function isPlausibleIsoDate(v) {\n  const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(String(v).trim());\n  if (!m) return false;\n  const month = Number(m[2]), day = Number(m[3]);\n  return month >= 1 && month <= 12 && day >= 1 && day <= 31;\n}\nif (!isPlausibleIsoDate(depart)) throw new Error(`invalid month/day: ${depart}`);","typeGuard":"function hasValidMonthDay(v) {\n  const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(String(v).trim());\n  return !!m && +m[2] >= 1 && +m[2] <= 12 && +m[3] >= 1 && +m[3] <= 31;\n}","tryCatchPattern":"try {\n  runTripCli(['flights', '--depart', depart]);\n} catch (err) {\n  if (err instanceof ArgumentError && /has invalid month\\/day/.test(err.message)) {\n    console.error(`Check month (01-12) and day (01-31) fields: ${err.message}`);\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Verify month/day field order when converting from MM/DD or DD/MM sources","Validate date components programmatically before passing to the CLI","Be careful with hand-typed dates in scripts and cron configs","Use a schema validator (zod, joi) on date inputs"],"tags":["cli","argument-validation","date"],"backgroundTag":"date-range-invalid","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}