santifer/career-ops · error

file not found

Error message

file not found: ${filePath}

What it means

validateFile() in validate-portals.mjs refuses to process a portals config file that does not exist on disk. It checks existsSync(filePath) before parsing YAML and throws a plain Error naming the missing path. This fail-fast guard prevents confusing downstream YAML/parse errors from a nonexistent file.

Solutions

  1. Verify the file exists at the exact path: ls -la portals.yml
  2. Run the validator from the repository root, or pass an absolute path
  3. If portals.yml is missing, create it: cp templates/portals.example.yml portals.yml
  4. Check for typos/case differences in the filename before re-running

Example fix

// before
await validateFile('protals.yml');
// after
await validateFile('portals.yml');
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs';
if (!existsSync('portals.yml')) {
  console.error('portals.yml missing — copy templates/portals.example.yml first');
  process.exit(1);
}

Type guard

const canValidate = (p) => typeof p === 'string' && p.length > 0 && existsSync(p);

Try / catch

try {
  await validateFile(cfgPath);
} catch (err) {
  if (err.message.startsWith('file not found')) {
    console.error(`Config missing: ${cfgPath}. Run from the repo root or create the file.`);
    process.exit(1);
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling validateFile('portals.yml') (directly or via the validator CLI) when the path was typo'd, the file was deleted/moved, or the command is run from a different working directory than where portals.yml lives.

Common situations: Running the validator before copying templates/portals.example.yml to portals.yml; wrong cwd (CI runs from repo subdirectory); shell variable expanding to empty; case-sensitive filename mismatch on Linux.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at validate-portals.mjs:284

      }

      validateParser(entry.parser, `${base}.parser`, errors);
    }
  };

  validateEntryList(config.tracked_companies, 'tracked_companies', 'company');
  validateEntryList(config.job_boards, 'job_boards', 'job board');

  return { errors, warnings };
}

function formatIssue(issue) {
  return `${issue.path}: ${issue.message}`;
}

async function validateFile(filePath) {
  if (!existsSync(filePath)) {
    throw new Error(`file not found: ${filePath}`);
  }
  const providerIds = await loadProviderIds();
  const parsed = yaml.load(readFileSync(filePath, 'utf-8'));
  return validatePortalsConfig(parsed, { providerIds });
}

async function runSelfTest() {
  const tmp = mkdtempSync(join(tmpdir(), 'career-ops-validate-portals-self-test-'));
  try {
    const file = join(tmp, 'bad.yml');
    writeFileSync(file, `
title_filter:
  positive: ["AI", ""]
tracked_companies:
  - name: "Acme"
    provider: "not-real"
    careers_url: "https://jobs.lever.co/acme"
`, 'utf-8');

View on GitHub (pinned to aac998c7ed)