{"record":{"id":"3a4b2d5771c2e2e3","repo":"santifer/career-ops","slug":"failed-to-read-cv-file-at-customcvpath-err-m","errorCode":null,"errorMessage":"Failed to read CV file at ${customCvPath}: ${err.message}","messagePattern":"Failed to read CV file at (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/export-ats-text.mjs","lineNumber":257,"sourceCode":"      if (!profileRaw || typeof profileRaw !== 'object') {\n        throw new Error('config/profile.yml is empty or invalid YAML: fill it in first');\n      }\n    } catch (err) {\n      throw new Error(`Failed to read profile file at ${profileSource}: ${err.message}`);\n    }\n  }\n\n  let cvData = {};\n  const cvSource = customCvPath || process.env.CAREER_OPS_CV || 'cv.md';\n  if (customCvPath) {\n    if (!existsSync(customCvPath)) {\n      throw new Error(`CV file not found at: ${customCvPath}`);\n    }\n    try {\n      const cvText = readFileSync(customCvPath, 'utf8');\n      cvData = parseCvMarkdown(cvText);\n    } catch (err) {\n      throw new Error(`Failed to read CV file at ${customCvPath}: ${err.message}`);\n    }\n  } else if (existsSync(cvSource)) {\n    try {\n      const cvText = readFileSync(cvSource, 'utf8');\n      cvData = parseCvMarkdown(cvText);\n    } catch {\n      // cv.md is optional if profile supplies necessary fields\n    }\n  }\n\n  return normalizeProfile(profileRaw, cvData);\n}\n\n/**\n * Formats profile object into structured plain-text section blocks.\n */\nexport function formatAtsText(profile = {}, options = {}) {\n  const normalized = normalizeProfile(profile);","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/scripts/export-ats-text.mjs#L239-L275","documentation":"Thrown by loadProfile() when an explicit customCvPath exists but reading or parsing it fails — readFileSync error or an exception from parseCvMarkdown(). The raw cause is wrapped into a single message naming the path.","triggerScenarios":"loadProfile(profilePath, customCvPath) where the file exists but is unreadable (permissions, directory) or parseCvMarkdown throws on malformed/unexpected markdown structure.","commonSituations":"CV file with permissions too restrictive; path is actually a directory; CV markdown restructured so a section the parser expects (headings, bullet format) is missing or malformed; binary file (e.g. a PDF) saved as .md.","solutions":["Read the wrapped err.message for the root cause (EACCES, EISDIR, or the parseCvMarkdown error text).","Confirm the file is plain-text UTF-8 markdown with the standard sections (Summary, Experience, Education, Skills).","Check permissions and that the path is a regular file (not a directory or symlink to nothing).","Restore cv.md structure per the project's convention (standard markdown headings) or re-export the CV."],"exampleFix":"# before: cv.md is a binary PDF renamed to .md\n$ file cv.md  # PDF document\n# after: keep the real markdown at cv.md, or convert first\n# pandoc cv.pdf -o cv.md","handlingStrategy":"try-catch","validationCode":"import { statSync, readFileSync } from 'node:fs';\nif (!statSync(cvPath).isFile()) throw new Error(`${cvPath} is not a regular file`);\nreadFileSync(cvPath, 'utf8'); // fails fast on permission/encoding problems","typeGuard":null,"tryCatchPattern":"try {\n  const profile = loadProfile(null, cvPath);\n} catch (err) {\n  if (err.message.includes(`Failed to read CV file at ${cvPath}`)) {\n    console.error(`CV unreadable: ${err.message}`);\n    const profile = loadProfile(null); // degrade gracefully without CV data\n  } else throw err;\n}","preventionTips":["Keep cv.md as plain UTF-8 markdown with standard sections (Summary, Experience, Education, Skills).","Never rename binary files (PDFs) to .md; convert them properly before use.","Check file permissions before running export scripts, especially in containers/CI."],"tags":["cv","file-read","markdown"],"backgroundTag":"file-read-failed","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"}