{"record":{"id":"104fba7b6a9e2314","repo":"santifer/career-ops","slug":"config-profile-yml-is-empty-or-invalid-yaml-fill","errorCode":null,"errorMessage":"config/profile.yml is empty or invalid YAML: fill it in first","messagePattern":"config/profile\\.yml is empty or invalid YAML: fill it in first","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/export-ats-text.mjs","lineNumber":240,"sourceCode":"    }\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';\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    }","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/scripts/export-ats-text.mjs#L222-L258","documentation":"Thrown by loadProfile() when the default profile source (config/profile.yml or CAREER_OPS_PROFILE) exists but yaml.load() yields null/undefined or a non-object — an empty or structurally invalid file. Like its custom-path counterpart, this inner throw is caught by the enclosing catch and re-wrapped as error 465, so the surfaced message is 'Failed to read profile file at config/profile.yml: ...'.","triggerScenarios":"loadProfile() with config/profile.yml present but empty, containing only comments, or parsing to a scalar/array rather than a mapping.","commonSituations":"Copied the example but emptied it; file truncated by a failed write; only comments left after removing placeholders; accidentally saved a different format (JSON array, plain text) as .yml.","solutions":["Open config/profile.yml and add a top-level YAML mapping with the required fields (name, email, roles, etc.).","Re-copy the template: cp config/profile.example.yml config/profile.yml and edit that.","Run the parsed output through a quick node/yaml check to see what the file currently parses to.","Restore the file from git history if it was valid before (git checkout -- config/profile.yml after checking a prior commit)."],"exampleFix":"# before: file contains only comments -> yaml.load returns null\n# after:\nname: Jane Doe\nemail: jane@example.com\nspend_tier: standard","handlingStrategy":"validation","validationCode":"const parsed = yaml.parse(readFileSync('config/profile.yml', 'utf8'));\nif (parsed === null || typeof parsed !== 'object') {\n  throw new Error('config/profile.yml is empty or not a mapping — fill it in from the example');\n}","typeGuard":"const hasProfileMapping = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);","tryCatchPattern":null,"preventionTips":["After copying the example template, actually fill in required fields before running scripts.","Add a CI smoke test that parses config/profile.yml and asserts it is a non-empty mapping.","Avoid saving non-YAML content (JSON arrays, plain text) into a .yml file."],"tags":["config","yaml","empty-file"],"backgroundTag":"yaml-parse-error","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"}