{"record":{"id":"4f58cf9e7f1fba94","repo":"santifer/career-ops","slug":"failed-to-read-profile-file-at-profilesource","errorCode":null,"errorMessage":"Failed to read profile file at ${profileSource}: ${err.message}","messagePattern":"Failed to read profile file at (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/export-ats-text.mjs","lineNumber":243,"sourceCode":"      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';\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');","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/santifer/career-ops/blob/1696bec4d021768e7359f9aad6b329cba883da20/scripts/export-ats-text.mjs#L225-L261","documentation":"The catch around the default-path profile read wraps every failure — fs errors on config/profile.yml/CAREER_OPS_PROFILE, YAML syntax exceptions, and the nested error 307 — into this single message with the path and the underlying err.message. It guarantees callers of the no-argument path always get one predictable error shape for an unloadable profile.","triggerScenarios":"existsSync passes but readFileSync then fails (permissions changed, file deleted in between, EISDIR), or yaml.load throws on malformed YAML, or the nested 'empty or invalid YAML' error fires — all rethrown here.","commonSituations":"config/profile.yml with tab indentation (js-yaml's classic failure); unquoted values containing ':' or '#'; CAREER_OPS_PROFILE pointing at a directory; unreadable file after chmod; Windows line-ending/BOM issues confusing the parser in edge setups.","solutions":["Inspect the appended err.message (e.g. 'bad indentation of a mapping entry', 'EACCES') and fix that specific cause.","Fix YAML formatting: spaces not tabs, quote strings containing special characters, keep one top-level mapping.","Restore a known-good file: `cp config/profile.example.yml config/profile.yml`, edit values, rerun.","Verify access: `ls -l config/profile.yml` and ensure it is a readable regular file owned by the running user."],"exampleFix":"// before (unquoted colon breaks YAML)\ntitle: Senior: Backend Engineer\n\n// after\ntitle: \"Senior: Backend Engineer\"","handlingStrategy":"try-catch","validationCode":"import { statSync } from 'node:fs';\nimport yaml from 'js-yaml';\nconst src = process.env.CAREER_OPS_PROFILE || 'config/profile.yml';\nconst st = statSync(src); // real fs error if unreadable/dir\nyaml.load(readFileSync(src, 'utf8')); // real syntax error if malformed","typeGuard":null,"tryCatchPattern":"try {\n  const profile = loadProfile();\n} catch (e) {\n  if (e.message.startsWith('Failed to read profile file at')) {\n    const cause = e.message.split(': ').slice(1).join(': ');\n    if (cause.includes('EACCES')) console.error('Fix permissions on config/profile.yml');\n    else if (cause.includes('ENOENT')) console.error('File vanished mid-run — recreate it');\n    else console.error('YAML syntax problem:', cause);\n  } else throw e;\n}","preventionTips":["Pre-validate the default profile with js-yaml directly to see syntax errors before the wrapper masks them.","Ensure CAREER_OPS_PROFILE points to a regular readable file, never a directory.","Quote YAML values containing ':', '#', or leading special characters; use spaces, never tabs.","Keep a known-good example file to restore from after bad edits."],"tags":["yaml","filesystem","error-wrapping","configuration"],"backgroundTag":"invalid-yaml-config","analyzedSha":"1696bec4d021768e7359f9aad6b329cba883da20","analyzedAt":"2026-09-01T19:19:23.111Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}