santifer/career-ops · error · Error
cv.md not found — cannot add to a CV that does not exist
Error message
cv.md not found — cannot add to a CV that does not exist
What it means
applyAdd is pure: it operates on the current file contents passed in as cvText. When the caller passes cvText === null — the sentinel meaning cv.md does not exist or could not be read — it refuses to add CV content, because insertIntoCvSection cannot invent a CV. Note article-digest.md is created from a default header when missing, but cv.md deliberately is not.
Solutions
- Create cv.md in the repo root first (paste your CV to the assistant, or write one from your LinkedIn/experience), then re-run the add.
- Fix the file-reading call site so it returns the file's text — and surfaces read errors instead of null.
- Run `node doctor.mjs --json` to confirm cv.md exists before invoking add flows.
Example fix
// before
const cvText = fs.existsSync('cv.md') ? null : fs.readFileSync('cv.md', 'utf8'); // inverted
applyAdd(payload, { cvText });
// after
const cvText = fs.existsSync('cv.md') ? fs.readFileSync('cv.md', 'utf8') : null;
if (cvText === null) throw new Error('cv.md missing — create it before adding entries');
applyAdd(payload, { cvText }); Defensive patterns
Strategy: validation
Validate before calling
const cvText = fs.existsSync(cvPath) ? fs.readFileSync(cvPath, 'utf8') : null;
if (payload.cv && cvText === null) {
throw new Error('Refusing to add: cv.md does not exist yet — create it first');
} Type guard
null
Try / catch
try {
applyAdd(payload, { cvText });
} catch (e) {
if (e.message.includes('cv.md not found')) {
console.error('Create cv.md in the repo root (or run onboarding) before adding CV entries');
} else throw e;
} Prevention
- Check cv.md existence (fs.existsSync / doctor.mjs) before running any add flow.
- Never swallow file-read errors into a null return — let ENOENT surface or handle it explicitly.
- Remember the asymmetry: article-digest.md is auto-created, cv.md is not — treat cv.md as a hard prerequisite.
When it happens
Trigger: Calling applyAdd({ cv: {...} }) with the options argument omitted (defaults cvText to null), reading cv.md with a helper that returns null on ENOENT, or running the add flow in a directory where cv.md was never created (onboarding not completed).
Common situations: Fresh career-ops checkout before onboarding (doctor.mjs reports cv.md as missing), a typo'd path passed to the file reader, or a script that swallows the read error and forwards null.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Could not parse existing candidates file at
- file not found
- ⚠️ not found
- not a regular file
- Sync check could not run
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/79421732be2e3a22.
Report an issue: GitHub.
Appendix: source
Thrown at add-entry.mjs:184
* contents and a per-target status. No I/O — this is what the tests exercise.
* @returns {{ cv: string, articleDigest: string, result: object }}
*/
export function applyAdd(payload, { cvText = null, articleText = null } = {}) {
if (!payload || typeof payload !== 'object' || (!payload.cv && !payload.articleDigest)) {
throw new Error('payload must include at least one of: cv, articleDigest');
}
const result = {};
let cv = cvText;
let articleDigest = articleText;
if (payload.cv) {
const { section, dedupKey, entry } = payload.cv;
if (!section || !entry) throw new Error('payload.cv requires { section, entry }');
// dedupKey is what makes the insert idempotent — refuse to add without one
// rather than silently allowing duplicate re-runs.
if (!normalizeKey(dedupKey)) throw new Error('payload.cv requires a non-empty dedupKey (used for dedup/idempotency)');
if (cvText === null) throw new Error(`cv.md not found — cannot add to a CV that does not exist`);
if (cvHasEntry(cvText, section, dedupKey)) {
result.cv = { status: 'duplicate', section };
} else {
cv = insertIntoCvSection(cvText, section, entry);
result.cv = { status: 'added', section };
}
}
if (payload.articleDigest) {
const { dedupKey, entry } = payload.articleDigest;
if (!entry) throw new Error('payload.articleDigest requires { entry }');
if (!normalizeKey(dedupKey)) throw new Error('payload.articleDigest requires a non-empty dedupKey (used for dedup/idempotency)');
// article-digest.md is optional; create it from a header when missing.
const current = articleText === null
? '# Article Digest -- Proof Points\n\nCompact proof points from portfolio projects. Read by career-ops at evaluation time.\n'
: articleText;
if (articleDigestHasEntry(current, dedupKey)) {
result.articleDigest = { status: 'duplicate' };View on GitHub (pinned to aac998c7ed)