{"record":{"id":"1eaf0f7298c24e8e","repo":"santifer/career-ops","slug":"file-not-found-filepath","errorCode":null,"errorMessage":"file not found: ${filePath}","messagePattern":"file not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"validate-portals.mjs","lineNumber":284,"sourceCode":"      }\n\n      validateParser(entry.parser, `${base}.parser`, errors);\n    }\n  };\n\n  validateEntryList(config.tracked_companies, 'tracked_companies', 'company');\n  validateEntryList(config.job_boards, 'job_boards', 'job board');\n\n  return { errors, warnings };\n}\n\nfunction formatIssue(issue) {\n  return `${issue.path}: ${issue.message}`;\n}\n\nasync function validateFile(filePath) {\n  if (!existsSync(filePath)) {\n    throw new Error(`file not found: ${filePath}`);\n  }\n  const providerIds = await loadProviderIds();\n  const parsed = yaml.load(readFileSync(filePath, 'utf-8'));\n  return validatePortalsConfig(parsed, { providerIds });\n}\n\nasync function runSelfTest() {\n  const tmp = mkdtempSync(join(tmpdir(), 'career-ops-validate-portals-self-test-'));\n  try {\n    const file = join(tmp, 'bad.yml');\n    writeFileSync(file, `\ntitle_filter:\n  positive: [\"AI\", \"\"]\ntracked_companies:\n  - name: \"Acme\"\n    provider: \"not-real\"\n    careers_url: \"https://jobs.lever.co/acme\"\n`, 'utf-8');","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/validate-portals.mjs#L266-L302","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the file exists at the exact path: ls -la portals.yml","Run the validator from the repository root, or pass an absolute path","If portals.yml is missing, create it: cp templates/portals.example.yml portals.yml","Check for typos/case differences in the filename before re-running"],"exampleFix":"// before\nawait validateFile('protals.yml');\n// after\nawait validateFile('portals.yml');","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nif (!existsSync('portals.yml')) {\n  console.error('portals.yml missing — copy templates/portals.example.yml first');\n  process.exit(1);\n}","typeGuard":"const canValidate = (p) => typeof p === 'string' && p.length > 0 && existsSync(p);","tryCatchPattern":"try {\n  await validateFile(cfgPath);\n} catch (err) {\n  if (err.message.startsWith('file not found')) {\n    console.error(`Config missing: ${cfgPath}. Run from the repo root or create the file.`);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Always run the validator from the repository root or pass absolute paths","Add a doctor/precheck that asserts required config files exist before CI steps","Keep a checked-in example (templates/portals.example.yml) and a setup step that copies it","Beware case-sensitive filenames when moving between OSes"],"tags":["file","validation","config"],"backgroundTag":"file-not-found","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"}