santifer/career-ops · error · Error
getEmployerProfile: id is required
Error message
getEmployerProfile: id is required
What it means
getEmployerProfile() in plugins/h1b-sponsor/lib/api.mjs requires a non-empty employer id. It sanitizes the argument with String(id || '').trim() and throws when nothing usable remains, before building the request URL.
Source
Thrown at plugins/h1b-sponsor/lib/api.mjs:547
red_flags: {
staffing_shop: staffing
? {
value: staffing.value === true,
share: typeof staffing.share === 'number' ? staffing.share : null,
n_secondary: staffing.n_secondary ?? null,
n_total: staffing.n_total ?? null,
basis: staffing.basis ?? null,
}
: null,
},
employer_name: employer.name ?? null,
employer_id: employer.id ?? employer.ein ?? null,
};
}
export async function getEmployerProfile(id, opts = {}) {
const sanitized = String(id || '').trim();
if (!sanitized) throw new Error('getEmployerProfile: id is required');
const url = `${apiBase()}/employers/${encodeURIComponent(sanitized)}`;
const raw = await requestJson(url, opts, { allow404: false });
return normalizeProfile(raw);
}
View on GitHub (pinned to 1696bec4d0)
Solutions
- Ensure the id comes from a successful prior lookup (e.g. a search result's employer id or EIN) before calling getEmployerProfile.
- Check the caller: log/inspect the value being passed; guard with `if (!id) return;` or throw a more contextual error upstream.
- If the company genuinely has no id, skip the profile call rather than calling it with an empty value.
Example fix
// before
const profile = await getEmployerProfile(searchResult?.id);
// after
if (!searchResult?.id) throw new Error(`No employer id found for ${companyName}`);
const profile = await getEmployerProfile(searchResult.id); Defensive patterns
Strategy: type-guard
Validate before calling
function hasEmployerId(x) {
return typeof x === 'string' ? x.trim().length > 0 : Boolean(x);
}
// before calling: if (!hasEmployerId(candidateId)) skip or raise a contextual error; Type guard
function isNonEmptyId(v) {
return (typeof v === 'string' || typeof v === 'number') && String(v).trim() !== '';
} Try / catch
try {
const profile = await getEmployerProfile(id);
} catch (e) {
if (e.message === 'getEmployerProfile: id is required') {
console.warn(`No employer id available for "${name}" — skipping profile lookup.`);
return null;
}
throw e;
} Prevention
- Only call getEmployerProfile with an id obtained from a successful prior search result.
- Pass the id field explicitly, never a whole record object.
- Guard optional-chained lookups (searchResult?.id) before calling.
- Fail fast upstream with a contextual message naming the company, so the empty id is diagnosable.
When it happens
Trigger: Calling getEmployerProfile(undefined), getEmployerProfile(null), getEmployerProfile(''), or getEmployerProfile(0) — any falsy or whitespace-only value — directly against the API-backed client.
Common situations: A lookup step returned undefined (company not found in a prior search) and its result was passed straight through; a variable name shadowed/misspelled so the id never got assigned; trimming whitespace-only user input.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- getEmployerProfile: id is required
- reportNum must be a numeric report number
- version must be a positive integer
- changedSections must be an array
- --limit must be an integer from 1 to 100
AI-assisted analysis of santifer/career-ops@1696bec4d0 (2026-09-01).
Data as JSON: /api/errors/ef02671dedb8c971.
Report an issue: GitHub.