santifer/career-ops · error
--from ( ) must not be after --to ( ).
Error message
--from (${from}) must not be after --to (${to}). What it means
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.
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
Example fix
// before
computeWeeklyDigest({ from: '2026-09-13', to: '2026-09-07' });
// after
computeWeeklyDigest({ from: '2026-09-07', to: '2026-09-13' }); Defensive patterns
Strategy: validation
Validate before calling
if (opts.from !== undefined && opts.to !== undefined && opts.from > opts.to) {
throw new Error(`--from (${opts.from}) must not be after --to (${opts.to})`);
} Try / catch
try {
const digest = computeWeeklyDigest(opts);
} catch (err) {
if (err.message.includes('must not be after')) {
console.error(`${err.message} — swap the dates and retry`);
process.exit(2);
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- --from and --to must both be supplied together (or neither…
- Application Answers section has
- Invalid page budget " ". Use a positive integer.
- --limit must be an integer from 1 to 100
- ⚠️ (proceeding — --allow-reorder set)
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/55d11e87885c88b3.
Report an issue: GitHub.
Appendix: source
Thrown at weekly-digest.mjs:318
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 an
// optional-data problem, not a reason to abort the whole digest — degrade
// to "no usable content" the same way a missing file does, but keepView on GitHub (pinned to aac998c7ed)