{"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/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/plugins/h1b-sponsor/check.mjs#L62-L98","documentation":"The H-1B sponsor plugin needs a data backend: either a locally installed SQLite index of public DOL data, or a remote HTTP endpoint configured via H1B_API_BASE. selectBackend throws when neither is present, i.e. no local index files were found on disk and no H1B_API_BASE environment variable is set. The message includes the exact install command.","triggerScenarios":"Calling any employer lookup (resolveEmployer/searchEmployers/getEmployerProfile via check.mjs) on a machine where install-h1b-index.mjs was never run and the H1B_API_BASE env var is unset.","commonSituations":"Fresh checkout or CI environment where the one-time index install was skipped; the index was installed under a different path than the backend expects; a user intended to use the HTTP backend but forgot to export H1B_API_BASE.","solutions":["Run `node plugins/h1b-sponsor/install-h1b-index.mjs` to download and install the local index (~8 MiB of public DOL data).","Alternatively set H1B_API_BASE to a trusted HTTP endpoint, e.g. export H1B_API_BASE=https://your-h1b-api.example.com, if you prefer remote lookups.","Verify the install actually wrote the index files to the expected location (re-run the installer; it is idempotent)."],"exampleFix":"// before (shell)\nnode plugins/h1b-sponsor/check.mjs \"Acme Corp\"   # throws\n// after\nnode plugins/h1b-sponsor/install-h1b-index.mjs\nnode plugins/h1b-sponsor/check.mjs \"Acme Corp\"","handlingStrategy":"fallback","validationCode":"import { existsSync } from 'node:fs';\nconst localReady = existsSync('plugins/h1b-sponsor/index.sqlite');\nconst remoteReady = Boolean(process.env.H1B_API_BASE);\nif (!localReady && !remoteReady) {\n  throw new Error('Run node plugins/h1b-sponsor/install-h1b-index.mjs or set H1B_API_BASE');\n}","typeGuard":"const backendAvailable = () =>\n  Boolean(process.env.H1B_API_BASE) || hasLocalIndex();","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 first: node plugins/h1b-sponsor/install-h1b-index.mjs');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Run the installer once per machine during setup (add it to your onboarding docs/Makefile).","Or set H1B_API_BASE in .env if you prefer remote lookups.","Check backend availability in CI before running lookups.","Note that a local index is preferred for privacy — lookups stay on-machine."],"tags":["config","setup","missing-dependency"],"backgroundTag":"missing-configuration","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"}