santifer/career-ops · error · Error

config/profile.yml is empty or invalid YAML: fill it in…

Error message

config/profile.yml is empty or invalid YAML: fill it in first

What it means

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: ...'.

Solutions

  1. Open config/profile.yml and add a top-level YAML mapping with the required fields (name, email, roles, etc.).
  2. Re-copy the template: cp config/profile.example.yml config/profile.yml and edit that.
  3. Run the parsed output through a quick node/yaml check to see what the file currently parses to.
  4. Restore the file from git history if it was valid before (git checkout -- config/profile.yml after checking a prior commit).

Example fix

# before: file contains only comments -> yaml.load returns null
# after:
name: Jane Doe
email: jane@example.com
spend_tier: standard
Defensive patterns

Strategy: validation

Validate before calling

const parsed = yaml.parse(readFileSync('config/profile.yml', 'utf8'));
if (parsed === null || typeof parsed !== 'object') {
  throw new Error('config/profile.yml is empty or not a mapping — fill it in from the example');
}

Type guard

const hasProfileMapping = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);

Prevention

When it happens

Trigger: loadProfile() with config/profile.yml present but empty, containing only comments, or parsing to a scalar/array rather than a mapping.

Common situations: 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.

Related errors


AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16). Data as JSON: /api/errors/104fba7b6a9e2314. Report an issue: GitHub.

Appendix: source

Thrown at scripts/export-ats-text.mjs:240

    }
    try {
      const content = readFileSync(customProfilePath, 'utf8');
      profileRaw = yaml.load(content);
      if (!profileRaw || typeof profileRaw !== 'object') {
        throw new Error(`Invalid YAML in profile file: ${customProfilePath}`);
      }
    } catch (err) {
      throw new Error(`Failed to read profile file at ${customProfilePath}: ${err.message}`);
    }
  } else {
    if (!existsSync(profileSource)) {
      throw new Error('config/profile.yml not found: fill it in first');
    }
    try {
      const content = readFileSync(profileSource, 'utf8');
      profileRaw = yaml.load(content);
      if (!profileRaw || typeof profileRaw !== 'object') {
        throw new Error('config/profile.yml is empty or invalid YAML: fill it in first');
      }
    } catch (err) {
      throw new Error(`Failed to read profile file at ${profileSource}: ${err.message}`);
    }
  }

  let cvData = {};
  const cvSource = customCvPath || process.env.CAREER_OPS_CV || 'cv.md';
  if (customCvPath) {
    if (!existsSync(customCvPath)) {
      throw new Error(`CV file not found at: ${customCvPath}`);
    }
    try {
      const cvText = readFileSync(customCvPath, 'utf8');
      cvData = parseCvMarkdown(cvText);
    } catch (err) {
      throw new Error(`Failed to read CV file at ${customCvPath}: ${err.message}`);
    }

View on GitHub (pinned to aac998c7ed)