{"record":{"id":"649eb3cdf023d868","repo":"santifer/career-ops","slug":"no-local-h-1b-index-and-no-h1b-api-base-install-t","errorCode":null,"errorMessage":"no local H-1B index and no H1B_API_BASE. Install the index with: node plugins/h1b-sponsor/install-h1b-index.mjs (about 8 MiB of public DOL data; lookups then stay on this machine). To use an HTTP endpoint instead, set H1B_API_BASE to one you trust.","messagePattern":"no local H-1B index and no H1B_API_BASE\\. Install the index with: node plugins/h1b-sponsor/install-h1b-index\\.mjs \\(about 8 MiB of public DOL data; lookups then stay on this machine\\)\\. To use an HTTP endpoint instead, set H1B_API_BASE to one you trust\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/h1b-sponsor/check.mjs","lineNumber":80,"sourceCode":"      opts: token ? { token } : {},\n      resolveEmployer: httpBackend.resolveEmployer,\n      searchEmployers: httpBackend.searchEmployers,\n      getEmployerProfile: httpBackend.getEmployerProfile,\n    };\n  }\n  if (localBackend.hasIndex()) {\n    return {\n      kind: 'index',\n      // The index digest, so a cached answer is tied to the exact data that\n      // produced it and a refreshed index invalidates the old numbers.\n      source: await localBackend.indexSource(),\n      opts: {},\n      resolveEmployer: localBackend.resolveEmployer,\n      searchEmployers: localBackend.searchEmployers,\n      getEmployerProfile: localBackend.getEmployerProfile,\n    };\n  }\n  throw new Error(\n    'no local H-1B index and no H1B_API_BASE. Install the index with: node plugins/h1b-sponsor/install-h1b-index.mjs '\n    + '(about 8 MiB of public DOL data; lookups then stay on this machine). To use an HTTP endpoint instead, '\n    + 'set H1B_API_BASE to one you trust.',\n  );\n}\n\n// Where the answer came from, reported back to the caller. The HTTP path names\n// the employer's own URL so the number can be checked by hand; the local path\n// names the index build, which is the equivalent handle for data on disk.\nfunction sourceRef(employerId) {\n  if (!backend) return null;\n  if (backend.kind === 'index') return backend.source;\n  return employerId\n    ? `${backend.source}/employers/${encodeURIComponent(employerId)}`\n    : `${backend.source}/employers`;\n}\n\n// Text from the backend goes through this before any non-JSON output, whether","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/santifer/career-ops/blob/1696bec4d021768e7359f9aad6b329cba883da20/plugins/h1b-sponsor/check.mjs#L62-L98","documentation":"selectBackend() resolves where H-1B employer lookups run: a local DOL data index or a remote HTTP endpoint (H1B_API_BASE). If neither is available — no installed local index and no API base configured — it throws this error with complete remediation instructions. The plugin deliberately requires an explicit choice between local privacy-preserving lookups and a trusted HTTP endpoint.","triggerScenarios":"Calling selectBackend (and thus any check/lookup flow) when the local index files are absent and the H1B_API_BASE environment variable is unset, so neither backend can be constructed.","commonSituations":"Fresh clone where install-h1b-index.mjs was never run; the index data directory deleted or gitignored and lost; deploying to CI where the ~8 MiB install step was skipped; user expected a hosted API but never set H1B_API_BASE.","solutions":["Run: node plugins/h1b-sponsor/install-h1b-index.mjs to install the ~8 MiB public DOL index locally.","Alternatively set H1B_API_BASE in .env to an H-1B lookup endpoint you trust.","Verify the install actually wrote the index files (check for the data directory under plugins/h1b-sponsor).","In CI/deployment, add the install step (or the env var) to your pipeline before any scan that uses the plugin."],"exampleFix":"# before (.env) — nothing set, index missing\n# after: either install\n#   node plugins/h1b-sponsor/install-h1b-index.mjs\n# or set:\nH1B_API_BASE=https://my-trusted-h1b-lookup.example.com","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nconst hasIndex = existsSync('plugins/h1b-sponsor/index-data');\nif (!hasIndex && !process.env.H1B_API_BASE) {\n  console.error('Run: node plugins/h1b-sponsor/install-h1b-index.mjs (or set H1B_API_BASE)');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const backend = await selectBackend();\n} catch (e) {\n  if (e.message.includes('no local H-1B index')) {\n    console.error('Install the index: node plugins/h1b-sponsor/install-h1b-index.mjs');\n    return null;\n  }\n  throw e;\n}","preventionTips":["Run the installer as part of repo setup (postinstall or onboarding checklist).","In CI, cache the installed index so the 8 MiB download happens once.","Decide explicitly: local index (private) vs H1B_API_BASE (trusted endpoint) — document the choice.","Check the index files exist after install before scheduling scans."],"tags":["configuration","setup","missing-data","h1b"],"backgroundTag":"missing-local-index","analyzedSha":"1696bec4d021768e7359f9aad6b329cba883da20","analyzedAt":"2026-09-01T19:19:23.111Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}