{"record":{"id":"d4914ce49c1bc586","repo":"santifer/career-ops","slug":"failed-to-read-profile-file-at-customprofilepath","errorCode":null,"errorMessage":"Failed to read profile file at ${customProfilePath}: ${err.message}","messagePattern":"Failed to read profile file at (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/export-ats-text.mjs","lineNumber":230,"sourceCode":" * Loads profile and CV data from file paths or default paths.\n * Fails closed if real profile configuration is missing.\n */\nexport function loadProfile(customProfilePath = null, customCvPath = null) {\n  let profileRaw = null;\n  const profileSource = customProfilePath || process.env.CAREER_OPS_PROFILE || 'config/profile.yml';\n\n  if (customProfilePath) {\n    if (!existsSync(customProfilePath)) {\n      throw new Error(`Profile configuration file not found at: ${customProfilePath}`);\n    }\n    try {\n      const content = readFileSync(customProfilePath, 'utf8');\n      profileRaw = yaml.load(content);\n      if (!profileRaw || typeof profileRaw !== 'object') {\n        throw new Error(`Invalid YAML in profile file: ${customProfilePath}`);\n      }\n    } catch (err) {\n      throw new Error(`Failed to read profile file at ${customProfilePath}: ${err.message}`);\n    }\n  } else {\n    if (!existsSync(profileSource)) {\n      throw new Error('config/profile.yml not found: fill it in first');\n    }\n    try {\n      const content = readFileSync(profileSource, 'utf8');\n      profileRaw = yaml.load(content);\n      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';","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/scripts/export-ats-text.mjs#L212-L248","documentation":"loadProfile() wraps any failure while reading or parsing an explicitly supplied custom profile file (readFileSync throw, YAML syntax error, or the inner invalid-YAML check) into this single error, preserving the underlying message. It exists so callers get one consistent message naming the offending path.","triggerScenarios":"loadProfile(customProfilePath) where the file exists but readFileSync fails (permissions, it is a directory) or yaml.load throws a syntax error, or the parsed result is not a non-null object.","commonSituations":"YAML indentation/tab errors; wrong permissions on the file; passing a directory path instead of a file; invalid characters or unclosed quotes/brackets in the YAML; the empty-file case from the inner invalid-YAML throw.","solutions":["Read the wrapped err.message suffix — it contains the root cause (ENOENT, EACCES, YAML syntax detail, or invalid YAML).","Paste the file into a YAML linter/parser to find the syntax error (tabs, bad indentation, unclosed strings).","Check file permissions and that the path is a regular file, not a directory.","Restore a known-good copy from config/profile.example.yml or version control."],"exampleFix":"// before\nmykey: \"unclosed value\n// after\nmykey: \"unclosed value\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const profile = loadProfile(customPath);\n} catch (err) {\n  if (err.message.includes(`Failed to read profile file at ${customPath}`)) {\n    console.error(`Root cause: ${err.message}`); // suffix carries the underlying read/parse error\n    // fall back to default: loadProfile(null)\n  } else throw err;\n}","preventionTips":["Lint YAML files (no tabs, consistent 2-space indentation) in CI.","Check file permissions and that the path is a regular file before passing it in.","Restore broken profiles from config/profile.example.yml rather than hand-patching syntax."],"tags":["config","yaml","file-read"],"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"}