{"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":"exception","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/1696bec4d021768e7359f9aad6b329cba883da20/scripts/export-ats-text.mjs#L222-L258","documentation":"This is the default-path twin of error 304: when the resolved profileSource (config/profile.yml or CAREER_OPS_PROFILE) exists but yaml.load returns null or a non-object, loadProfile throws this message. Like 304, it is immediately caught by the surrounding catch and rethrown as error 308 with the original cause appended, so users usually see the wrapper text.","triggerScenarios":"config/profile.yml (or the CAREER_OPS_PROFILE target) exists but parses to null/primitive: empty file, comments-only file, bare scalar, lone '---', or YAML that js-yaml rejects and then the catch rewraps.","commonSituations":"Running `cp config/profile.example.yml config/profile.yml` and forgetting to edit it (template is fine, but truncated/emptied copies happen); a save failure zeroed the file; a botched sed/script edit; a merge conflict left only markers that parse oddly.","solutions":["Open config/profile.yml and ensure it contains a complete top-level YAML mapping with real values; re-copy from config/profile.example.yml and edit if in doubt.","Validate independently: `node -e \"const y=require('js-yaml'),f=require('fs');console.log(y.load(f.readFileSync('config/profile.yml','utf8')))\"` and fix whatever prints null or throws.","If the wrapper error (308) appears instead, follow its appended err.message to the specific YAML syntax problem."],"exampleFix":"// before (profile.yml)\n---\n\n// after (profile.yml)\nname: Ada Lovelace\nemail: ada@example.com\nphone: \"+886 900 000 000\"\nlocation: Taipei\nlinkedin: https://www.linkedin.com/in/ada","handlingStrategy":"type-guard","validationCode":"import { readFileSync } from 'node:fs';\nimport yaml from 'js-yaml';\nconst doc = yaml.load(readFileSync('config/profile.yml', 'utf8'));\nif (!doc || typeof doc !== 'object') {\n  throw new Error('config/profile.yml is empty or scalar — restore from config/profile.example.yml and edit');\n}","typeGuard":"function isValidProfileDoc(v) {\n  return v !== null && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length > 0;\n}","tryCatchPattern":"try {\n  const profile = loadProfile();\n} catch (e) {\n  if (e.message.includes('empty or invalid YAML')) {\n    console.error('config/profile.yml parsed to nothing — refill it from config/profile.example.yml.');\n  } else throw e;\n}","preventionTips":["After copying the example profile, verify the file parses to a non-empty object before committing to use.","Guard against editor/truncation mishaps: check file size > 0 in setup scripts.","Treat merge conflicts in profile.yml as blockers — resolve fully, don't commit marker-laden YAML."],"tags":["yaml","configuration","empty-file","onboarding"],"backgroundTag":"invalid-yaml-config","analyzedSha":"1696bec4d021768e7359f9aad6b329cba883da20","analyzedAt":"2026-09-01T19:19:23.111Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}