santifer/career-ops · error · Error
H1B_API_BASE is set but empty. Unset it to use the default…
Error message
H1B_API_BASE is set but empty. Unset it to use the default endpoint.
What it means
resolveBase throws this when the H1B_API_BASE environment variable is defined but empty (or whitespace-only). The plugin deliberately refuses to fall back silently to the default endpoint, because an empty value usually means a configuration mistake (unset CI secret, blank .env line) and silently falling back would send the user's shortlist and token to a host they believed they had replaced.
Solutions
- Set H1B_API_BASE to the intended https:// base URL, or unset it entirely (`unset H1B_API_BASE`) to use the default endpoint.
- Remove the empty `H1B_API_BASE=` line from your .env file.
- Fix the CI secret so it actually contains a value before the job runs.
Example fix
// before (shell) export H1B_API_BASE= // after unset H1B_API_BASE # use default endpoint # or export H1B_API_BASE=https://my-h1b-worker.example.com
Defensive patterns
Strategy: validation
Validate before calling
if (process.env.H1B_API_BASE !== undefined && !process.env.H1B_API_BASE.trim()) {
throw new Error('H1B_API_BASE is set but empty; unset it or give it a value');
} Try / catch
try {
await getEmployerProfile(id);
} catch (e) {
if (e.message.includes('H1B_API_BASE is set but empty')) {
console.error('Fix your environment: unset H1B_API_BASE or fill in a valid https URL.');
}
} Prevention
- In .env files, comment out the whole line (`# H1B_API_BASE=...`) instead of leaving `H1B_API_BASE=`.
- Validate required env vars at process startup, before any API call.
- In CI, assert secrets are non-empty before the job step that uses them.
When it happens
Trigger: Calling any API function (e.g. getEmployerProfile) with H1B_API_BASE exported as an empty string: `export H1B_API_BASE=` in the shell, `H1B_API_BASE=` in .env, or a CI secret that did not populate.
Common situations: CI pipeline where the secret variable exists but has no value; a commented-out .env line leaving `H1B_API_BASE=` behind; copying a .env template without filling in the value.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- H1B_API_BASE is not a valid URL
- H1B_API_BASE must not contain a query string or a fragment.
- a16z-speedrun-talent: invalid URL
- agentic-jobs: invalid URL
- APIFY_TOKEN not set
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/9060d962eb973d07.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/h1b-sponsor/lib/api.mjs:43
let resolvedBase;
export function apiBase() {
// Only a successful resolve is memoized; a bad value keeps throwing so the
// failure cannot be masked by an earlier call that happened to succeed.
if (resolvedBase === undefined) resolvedBase = resolveBase();
return resolvedBase;
}
function resolveBase() {
const raw = process.env.H1B_API_BASE;
// Absent means "use the default". Present but blank is a misconfiguration
// (an unset shell variable, an empty .env line, a CI secret that did not
// populate), and silently falling back would send someone's shortlist and
// their token to a host they believed they had replaced.
if (raw === undefined) return DEFAULT_BASE;
const trimmed = String(raw).trim();
if (!trimmed) {
throw new Error('H1B_API_BASE is set but empty. Unset it to use the default endpoint.');
}
let parsed;
try {
parsed = new URL(trimmed);
} catch {
throw new Error(`H1B_API_BASE is not a valid URL: ${trimmed}`);
}
if (parsed.username || parsed.password) {
// Undici refuses a credentialed Request anyway, and the value reaches
// stdout through the source field, so this would print a password.
throw new Error('H1B_API_BASE must not embed credentials.');
}
if (parsed.search || parsed.hash) {
// Paths are appended, so a query or fragment swallows them: the request
// would go to the base itself and answer about a company never asked for.
throw new Error('H1B_API_BASE must not contain a query string or a fragment.');
}View on GitHub (pinned to aac998c7ed)