{"record":{"id":"55d11e87885c88b3","repo":"santifer/career-ops","slug":"from-from-must-not-be-after-to-to","errorCode":null,"errorMessage":"--from (${from}) must not be after --to (${to}).","messagePattern":"--from \\((.+?)\\) must not be after --to \\((.+?)\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"weekly-digest.mjs","lineNumber":318,"sourceCode":"  from,\n  to,\n  sessionsDir = DEFAULT_SESSIONS_DIR,\n  questionBankPath = DEFAULT_QUESTION_BANK_PATH,\n} = {}) {\n  // Range resolution has three cases, not two:\n  //   - neither --from nor --to given -> default current-week range (unchanged)\n  //   - exactly one of --from/--to given -> ambiguous, hard error (was:\n  //     silently fell back to the default range, which quietly discarded\n  //     the one bound the caller did supply)\n  //   - both given but from > to -> hard error (was: silently returned an\n  //     empty digest, indistinguishable from \"no interviews this week\")\n  let range;\n  if (from === undefined && to === undefined) {\n    range = computeDefaultRange();\n  } else if (from === undefined || to === undefined) {\n    throw new Error('--from and --to must both be supplied together (or neither, to use the default current-week range).');\n  } else if (from > to) {\n    throw new Error(`--from (${from}) must not be after --to (${to}).`);\n  } else {\n    range = { from, to };\n  }\n\n  const allSessions = loadSessions(sessionsDir);\n  const sessionsInRange = allSessions.filter((s) => inRange(s.date, range.from, range.to));\n\n  const companyNames = [...new Set(sessionsInRange.map((s) => s.company))];\n  // \"File exists\" and \"file has usable content\" are independent questions —\n  // an existing-but-empty question-bank.md is a different state than a\n  // missing one, and the metadata (and printSummary's \"present but\n  // unmatched\" branch) needs to be able to tell them apart.\n  const questionBankFound = existsSync(questionBankPath);\n  // existsSync() succeeding doesn't guarantee readFileSync() will: the path\n  // could be a directory, permissions could block the read, or the file\n  // could be deleted between the two calls (TOCTOU). Any of those is an\n  // optional-data problem, not a reason to abort the whole digest — degrade\n  // to \"no usable content\" the same way a missing file does, but keep","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/weekly-digest.mjs#L300-L336","documentation":"computeWeeklyDigest() rejects an inverted date range: when both --from and --to are given and from > to, it throws '--from (${from}) must not be after --to (${to})'. The check exists (per the surrounding comment) because an inverted range previously produced a silently empty digest, indistinguishable from a week with no interviews.","triggerScenarios":"Calling with from set to a later date than to — e.g. swapped arguments, a negative interval, or variables computed in the wrong order (end assigned to from).","commonSituations":"Swapped CLI flags (--to 2026-09-07 --from 2026-09-13); timezone/locale parsing producing swapped day-month; scripting where endDate < startDate due to an arithmetic bug.","solutions":["Swap the values so --from is the earlier date and --to the later one","Verify dates with date -d <value> or new Date(v) to confirm parsing/order","Fix the wrapper code that computes start/end so start <= end"],"exampleFix":"// before\ncomputeWeeklyDigest({ from: '2026-09-13', to: '2026-09-07' });\n// after\ncomputeWeeklyDigest({ from: '2026-09-07', to: '2026-09-13' });","handlingStrategy":"validation","validationCode":"if (opts.from !== undefined && opts.to !== undefined && opts.from > opts.to) {\n  throw new Error(`--from (${opts.from}) must not be after --to (${opts.to})`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const digest = computeWeeklyDigest(opts);\n} catch (err) {\n  if (err.message.includes('must not be after')) {\n    console.error(`${err.message} — swap the dates and retry`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Compute start/end in one place and assert start <= end before invoking","Use ISO YYYY-MM-DD consistently to avoid locale parsing surprises","Never pass user-supplied dates without normalizing order"],"tags":["date-range","validation","cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}