santifer/career-ops · error · Error
yourator: unexpected API response on page
Error message
yourator: unexpected API response on page ${page} — expected { payload: { jobs: [...] } }, got keys: [${json ? Object.keys(json).join(', ') : 'null'}] What it means
The yourator provider fetches each results page and requires the JSON body to have the shape { payload: { jobs: [...] } }. If json is null, payload is missing, or payload.jobs is not an array, fetch throws this error naming the page number and the top-level keys actually received. It guards against API redesigns, empty/blocked responses, and HTML error bodies masquerading as parsed JSON.
Solutions
- Print the failing page's raw body to see the actual keys returned (the error already lists top-level keys)
- If it happens only past the last page, treat a missing jobs array on an empty page as end-of-results instead of an error (guard with break on empty payload)
- Check whether Yourator renamed payload/jobs and update the destructuring in fetch/normalizeYouratorJob accordingly
- Retry once on transient failures; if a WAF blocks you, add proper headers or use a residential network
Example fix
// before
const jobs = json?.payload?.jobs;
if (!Array.isArray(jobs)) throw new Error(...);
// after: tolerate empty final page
const jobs = json?.payload?.jobs;
if (!Array.isArray(jobs)) {
if (page > 1 && json && Object.keys(json).length === 0) break;
throw new Error(`yourator: unexpected API response on page ${page}`);
} Defensive patterns
Strategy: type-guard
Validate before calling
// cheap preflight on page 1 before looping pages
const first = await ctx.fetchJson(`${FEED_BASE}?page=1`, { redirect: 'error' });
if (!first?.payload || !Array.isArray(first.payload.jobs)) {
throw new Error(`yourator envelope changed: keys=${Object.keys(first ?? {}).join(',')}`);
} Type guard
function isYouratorJobsPage(json) {
return !!json && typeof json === 'object' &&
typeof json.payload === 'object' && json.payload !== null &&
Array.isArray(json.payload.jobs);
} Try / catch
try {
await scanYourator(entry);
} catch (e) {
if (e.message.startsWith('yourator: unexpected API response')) {
console.warn('Check the raw page body — envelope rename, empty last page, or WAF block.');
} else throw e;
} Prevention
- Stop paginating when a page returns an empty/shapeless payload instead of erroring
- Record a fixture of a real page response and test normalizeYouratorJob against it
- Use redirect:'error' and realistic headers to avoid WAF/redirect interference
- Watch for Yourator API version announcements that rename payload/jobs
When it happens
Trigger: Yourator changes its response envelope (renames payload or jobs), the page exceeds the available results and returns an empty object, a CDN/WAF returns an error JSON, or the fetch silently got a non-API response.
Common situations: Yourator ships an API v2 renaming fields; requesting page N beyond the last page for a company with few jobs; anti-bot challenge on a datacenter IP; transient API outage returning an error envelope.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- justjoin: unexpected API response — expected
- wttj: unexpected Algolia response for query
- yourator: invalid URL
- 4dayweek: unexpected API response on page
- a16z-speedrun-talent: unexpected API response on page
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/9410874c859510a0.
Report an issue: GitHub.
Appendix: source
Thrown at providers/yourator.mjs:189
/** @type {Provider} */
export default {
id: 'yourator',
async fetch(entry, ctx) {
assertYouratorUrl(FEED_BASE);
// ctx.maxPages is verify-portals.mjs's "first page only" health probe — it
// always wins over the entry's own bound.
const maxPages = Math.min(resolveMaxPages(entry), ctx?.maxPages ?? Number.POSITIVE_INFINITY);
const fallbackCompany = entry?.name;
const out = [];
for (let page = 1; page <= maxPages; page++) {
const url = `${FEED_BASE}?page=${page}`;
// redirect:'error' prevents SSRF via server-side redirects
const json = await ctx.fetchJson(url, { redirect: 'error' });
const jobs = json?.payload?.jobs;
if (!Array.isArray(jobs)) {
throw new Error(
`yourator: unexpected API response on page ${page} — expected { payload: { jobs: [...] } }, got keys: [${json ? Object.keys(json).join(', ') : 'null'}]`,
);
}
for (const j of jobs) {
const normalized = normalizeYouratorJob(j, fallbackCompany);
if (normalized) out.push(normalized);
}
// `hasMore` is the API's own end-of-board signal and the only stop
// condition: past the last page it answers with an empty array and
// hasMore:false. A short-page heuristic is deliberately NOT used — it
// cannot help (maxPages already bounds a runaway walk) and a single short
// intermediate page would silently truncate the board.
if (json.payload.hasMore !== true) break;
if (page < maxPages) {
await (ctx.sleep ? ctx.sleep(PAGE_DELAY_MS) : new Promise(r => setTimeout(r, PAGE_DELAY_MS)));
}
}
return out;View on GitHub (pinned to aac998c7ed)