{"record":{"id":"a1372f5f6eecb0df","repo":"santifer/career-ops","slug":"from-and-to-must-both-be-supplied-together-or","errorCode":null,"errorMessage":"--from and --to must both be supplied together (or neither, to use the default current-week range).","messagePattern":"--from and --to must both be supplied together \\(or neither, to use the default current-week range\\)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"weekly-digest.mjs","lineNumber":301,"sourceCode":" */\nexport function computeWeeklyDigest({\n  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","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/santifer/career-ops/blob/60398d6549a46f5266929538af21cfab94badc75/weekly-digest.mjs#L283-L319","documentation":"weekly-digest.mjs's range resolution treats a half-supplied date range as a hard error: if exactly one of --from/--to is given, the bound the caller did supply would previously be silently discarded in favor of the default current-week range — now it throws instead. Deliberate ambiguity refusal, documented inline.","triggerScenarios":"`node weekly-digest.mjs --from 2026-08-10` without --to (or --to alone without --from). The two flags must be supplied together or both omitted for the default current-week range.","commonSituations":"Trying to digest 'everything since date X' (the tool has no open-ended range); shell scripts passing one bound conditionally; typos dropping one flag from a copied command.","solutions":["Supply both bounds: add the missing --to with an explicit end date","For a single week, omit both flags (default current-week range) or pass the week's Monday and Sunday","If you truly want 'since X', pass --from X with --to set to today's date"],"exampleFix":"# before\nnode weekly-digest.mjs --from 2026-08-10\n# after\nnode weekly-digest.mjs --from 2026-08-10 --to 2026-08-16","handlingStrategy":"validation","validationCode":"const hasFrom = argv.includes('--from');\nconst hasTo = argv.includes('--to');\nif (hasFrom !== hasTo) {\n  console.error('--from and --to must be supplied together (or both omitted)');\n  process.exit(2);\n}","typeGuard":"function isValidRangeArgs(from, to) {\n  return (from === undefined) === (to === undefined);\n}","tryCatchPattern":"try {\n  await runDigest({ from, to });\n} catch (err) {\n  if (err.message.includes('must both be supplied together')) {\n    // supply the missing bound explicitly; there is no open-ended range mode\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Treat --from/--to as an atomic pair in scripts and cron entries","For 'current week' simply omit both flags","Use ISO YYYY-MM-DD so the pair also survives the from<=to check"],"tags":["cli","date-range","validation","weekly-digest"],"backgroundTag":"invalid-date-range","analyzedSha":"60398d6549a46f5266929538af21cfab94badc75","analyzedAt":"2026-08-20T23:00:06.764Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}