{"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":null,"httpStatus":null,"severity":"error","filePath":"weekly-digest.mjs","lineNumber":316,"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":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/weekly-digest.mjs#L298-L334","documentation":"computeWeeklyDigest() in weekly-digest.mjs validates its optional from/to date-range arguments as a pair. Supplying exactly one of --from or --to (leaving the other undefined) throws this error, because a half-specified range is ambiguous. Passing neither uses the default current-week range; passing both is validated separately.","triggerScenarios":"Calling computeWeeklyDigest({from}) or computeWeeklyDigest({to}) with only one bound, or the CLI invoked with --from but no --to (or vice versa).","commonSituations":"Scripting the digest with a variable start date but forgetting the end date; editing a command to remove one of the two flags; a wrapper passing null/undefined for just one bound.","solutions":["Pass both --from and --to together: node weekly-digest.mjs --from 2026-09-07 --to 2026-09-13","Pass neither to use the default current-week range","Fix the calling wrapper so both bounds are computed/passed or both omitted"],"exampleFix":"// before\ncomputeWeeklyDigest({ from: '2026-09-07' });\n// after\ncomputeWeeklyDigest({ from: '2026-09-07', to: '2026-09-13' });","handlingStrategy":"validation","validationCode":"if ((opts.from === undefined) !== (opts.to === undefined)) {\n  throw new Error('--from and --to must both be supplied together (or neither)');\n}","typeGuard":"const hasRange = (o) => (o.from !== undefined && o.to !== undefined) || (o.from === undefined && o.to === undefined);","tryCatchPattern":"try {\n  const digest = computeWeeklyDigest(opts);\n} catch (err) {\n  if (err.message.includes('must both be supplied together')) {\n    console.error(`${err.message}\\nExample: --from 2026-09-07 --to 2026-09-13`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Treat from/to as a pair in wrapper code — build both or neither","Default to omitting both flags to use the current-week range","Unit-test CLI wrappers with one-flag-only cases"],"tags":["cli","date-range","validation"],"backgroundTag":"mutually-exclusive-flags","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"}