{"record":{"id":"25c47cfa8b818b14","repo":"santifer/career-ops","slug":"invalid-yaml-in-profile-file-customprofilepath","errorCode":null,"errorMessage":"Invalid YAML in profile file: ${customProfilePath}","messagePattern":"Invalid YAML in profile file: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/export-ats-text.mjs","lineNumber":227,"sourceCode":"}\n\n/**\n * 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  }","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/scripts/export-ats-text.mjs#L209-L245","documentation":"Thrown by loadProfile() when the custom profile YAML parses (or the file reads) but yaml.load() returns null/undefined or a non-object — i.e. the file is empty or contains a scalar/array instead of a mapping. Note this inner throw is immediately caught by the surrounding catch and re-wrapped as error 462 ('Failed to read profile file at ...'), so you will normally see the wrapped message with this text as its cause.","triggerScenarios":"loadProfile(customProfilePath) where the file exists but yaml.load(content) yields a falsy or non-object value: empty file, file containing only comments, a bare string/number, or 'null'.","commonSituations":"Profile file created but never filled in; an editor/save glitch truncated it to zero bytes; someone wrote JSON-in-YAML that serializes to a scalar; a placeholder file with only comments.","solutions":["Open the file and ensure it contains a valid YAML mapping (key: value pairs), not empty content or a bare scalar.","Re-copy the template: cp config/profile.example.yml <your-profile-path> and edit it.","Validate the YAML independently (e.g. node -e \"console.log(require('yaml').parse(require('fs').readFileSync(p,'utf8')))\" ) to see what it parses to.","Check for encoding issues (BOM/UTF-16) that can make the parser return unexpected values."],"exampleFix":"// before: profile.yml contains only '# TODO fill in' (parses to null)\n// after: give it a mapping\nname: Jane Doe\nemail: jane@example.com\ntarget_role: Senior Backend Engineer","handlingStrategy":"validation","validationCode":"const parsed = yaml.parse(readFileSync(profilePath, 'utf8'));\nif (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {\n  throw new Error(`${profilePath} must contain a YAML mapping, not be empty or a scalar`);\n}","typeGuard":"const isYamlMapping = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);","tryCatchPattern":null,"preventionTips":["Never commit an empty or comment-only profile file; validate it in CI with a quick yaml.parse smoke test.","Ensure the top level of profile.yml is a mapping (key: value), not a list or scalar.","Add a pre-commit hook or doctor-style check that parses the profile and reports 'empty/invalid'."],"tags":["config","yaml","validation"],"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"}