santifer/career-ops · error · Error
4dayweek: unexpected API response on page
Error message
4dayweek: unexpected API response on page ${page} — expected { jobs: [...] }, got keys: [${json ? Object.keys(json).join(', ') : 'null'}] What it means
Thrown by the 4dayweek provider's fetch when a page of its paginated feed does not return JSON with a `jobs` array. The provider validates every page's shape (json truthy and Array.isArray(json.jobs)) before normalizing, because a changed API contract, an HTML error page parsed as JSON, or an empty/odd response would otherwise silently produce zero results. The message includes the actual top-level keys (or 'null') to aid diagnosis.
Solutions
- Log/fetch the URL manually and inspect the actual JSON keys reported in the error to see what the API now returns.
- Check whether the feed API moved or changed its schema and update the provider's parsing to match.
- Reduce max_pages or stop paginating at the first empty page if the error occurs on a high page number beyond the feed's end.
- If an intermediary (proxy/WAF) is rewriting responses, bypass or fix it so the real feed JSON reaches the provider.
Defensive patterns
Strategy: try-catch
Validate before calling
const json = await res.json();
if (!json || !Array.isArray(json.jobs)) {
throw new Error(`feed shape changed: keys=${Object.keys(json ?? {}).join(',')}`);
} Type guard
function isJobsPage(json) {
return typeof json === 'object' && json !== null && Array.isArray(json.jobs);
} Try / catch
try {
const jobs = await fetch4dayweekPage(page);
} catch (e) {
if (String(e.message).includes('unexpected API response')) {
console.error('4dayweek feed schema may have changed; inspect the keys in the message');
return []; // or alert, per policy
} else throw e;
} Prevention
- Validate response shape at the fetch boundary with a small guard function.
- Watch for feed API schema changes after provider updates.
- Stop paginating when a page returns an empty or malformed body instead of pushing past the last page.
- Pin/monitor the feed endpoint so outages and WAF rewrites are noticed early.
When it happens
Trigger: fetchJson on `${FEED_BASE}?page=${page}` returns null, a JSON object without a `jobs` key, or a `jobs` value that is not an array — e.g. the API moved/changed schema, an error payload like {error:'...'}, or a proxy returning JSON-RPC/HTML-as-JSON.
Common situations: The 4dayweek feed API changed its response shape; requesting a page beyond the last page; a captive portal or WAF returning JSON error bodies with 200 status; CDN serving an error object during an outage.
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
- a16z-speedrun-talent: unexpected API response on page
- agentic-jobs: unexpected API response shape on page
- arbeitnow: unexpected API response on page
- collage: unrecognized response envelope (expected a…
- flowxtra: unexpected API response on page
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/49bec4804fc3093f.
Report an issue: GitHub.
Appendix: source
Thrown at providers/4dayweek.mjs:145
/** @type {Provider} */
export default {
id: '4dayweek',
detect: detectFourDayEntry,
async fetch(entry, ctx) {
assertFourDayUrl(FEED_BASE);
const maxPages = resolveMaxPages(entry);
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' });
if (!json || !Array.isArray(json.jobs)) {
throw new Error(
`4dayweek: unexpected API response on page ${page} — expected { jobs: [...] }, got keys: [${json ? Object.keys(json).join(', ') : 'null'}]`,
);
}
for (const j of json.jobs) {
const normalized = normalize4dwJob(j, fallbackCompany);
if (normalized) out.push(normalized);
}
if (json.has_more === false) break; // last page per the API flag
if (json.jobs.length < PER_PAGE) break; // short page → last page
}
return out;
},
};
View on GitHub (pinned to aac998c7ed)