santifer/career-ops · error · Error
--from and --to must both be supplied together (or neither,
Error message
--from and --to must both be supplied together (or neither, to use the default current-week range).
What it means
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.
Source
Thrown at weekly-digest.mjs:301
*/
export function computeWeeklyDigest({
from,
to,
sessionsDir = DEFAULT_SESSIONS_DIR,
questionBankPath = DEFAULT_QUESTION_BANK_PATH,
} = {}) {
// Range resolution has three cases, not two:
// - neither --from nor --to given -> default current-week range (unchanged)
// - exactly one of --from/--to given -> ambiguous, hard error (was:
// silently fell back to the default range, which quietly discarded
// the one bound the caller did supply)
// - both given but from > to -> hard error (was: silently returned an
// empty digest, indistinguishable from "no interviews this week")
let range;
if (from === undefined && to === undefined) {
range = computeDefaultRange();
} else if (from === undefined || to === undefined) {
throw new Error('--from and --to must both be supplied together (or neither, to use the default current-week range).');
} else if (from > to) {
throw new Error(`--from (${from}) must not be after --to (${to}).`);
} else {
range = { from, to };
}
const allSessions = loadSessions(sessionsDir);
const sessionsInRange = allSessions.filter((s) => inRange(s.date, range.from, range.to));
const companyNames = [...new Set(sessionsInRange.map((s) => s.company))];
// "File exists" and "file has usable content" are independent questions —
// an existing-but-empty question-bank.md is a different state than a
// missing one, and the metadata (and printSummary's "present but
// unmatched" branch) needs to be able to tell them apart.
const questionBankFound = existsSync(questionBankPath);
// existsSync() succeeding doesn't guarantee readFileSync() will: the path
// could be a directory, permissions could block the read, or the file
// could be deleted between the two calls (TOCTOU). Any of those is anView on GitHub (pinned to 60398d6549)
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
Example fix
# before node weekly-digest.mjs --from 2026-08-10 # after node weekly-digest.mjs --from 2026-08-10 --to 2026-08-16
Defensive patterns
Strategy: validation
Validate before calling
const hasFrom = argv.includes('--from');
const hasTo = argv.includes('--to');
if (hasFrom !== hasTo) {
console.error('--from and --to must be supplied together (or both omitted)');
process.exit(2);
} Type guard
function isValidRangeArgs(from, to) {
return (from === undefined) === (to === undefined);
} Try / catch
try {
await runDigest({ from, to });
} catch (err) {
if (err.message.includes('must both be supplied together')) {
// supply the missing bound explicitly; there is no open-ended range mode
process.exit(2);
}
throw err;
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- --from (${from}) must not be after --to (${to}).
- NOT_APPLIED
- --${name} is required
- --${name} must not contain tabs or newlines
- --${name} must be a percentage (e.g. 70 or 70%), got "${v}"
AI-assisted analysis of santifer/career-ops@60398d6549 (2026-08-20).
Data as JSON: /api/errors/a1372f5f6eecb0df.
Report an issue: GitHub.