santifer/career-ops · error · Error
themuse: unexpected API response on page 0 — expected
Error message
themuse: unexpected API response on page 0 — expected { results: [...] }, got keys: [${first ? Object.keys(first).join(', ') : 'null'}] What it means
The themuse provider fetches page 0 outside the retry-tolerant loop and treats it as the schema probe: the response must be an object with a results array, from which page_count is read. Anything else (null body, an error object, HTML-as-text) throws immediately, because without a valid first page the provider cannot determine pagination or any results at all.
Solutions
- Re-run the scan — first-page failures here are often transient upstream problems.
- Open the feed URL in a browser or curl it to inspect the actual body (the error lists the top-level keys you got instead).
- Check the Muse developer status/changelog for API schema or version changes and update the provider if the envelope changed.
- Verify any API key/plan requirements for the public job feed and that your rate isn't being throttled into error bodies.
Example fix
// before (provider expects old envelope)
if (!first || !Array.isArray(first.results)) throw new Error(...);
// after — if Muse moved to a data envelope, adapt the probe
const results = first?.results ?? first?.data;
if (!results || !Array.isArray(results)) throw new Error('themuse: no results array in response'); Defensive patterns
Strategy: try-catch
Validate before calling
function isMuseFirstPage(json) {
return !!json && typeof json === 'object' && Array.isArray(json.results);
}
// probe before depending on pagination:
// const probe = await fetch(`${FEED_BASE}?page=0`).then(r => r.json());
// if (!isMuseFirstPage(probe)) the API is down or changed — don't run the scan Type guard
const hasResults = (v) => v !== null && typeof v === 'object' && Array.isArray(v.results);
Try / catch
try {
return await themuseProvider.fetch(entry, ctx);
} catch (err) {
if (String(err.message).includes('unexpected API response on page 0')) {
console.error(`themuse feed unavailable or schema changed for ${entry.name}: ${err.message}`);
return { jobs: [], degraded: true }; // skip this scan round
}
throw err;
} Prevention
- Health-check the Muse feed URL with curl before scheduled scans
- Subscribe to / watch Muse developer status for schema or version announcements
- Keep a fixture of a valid page-0 response and validate it in CI against the provider's expectations
- Treat recurring page-0 failures as an upstream outage signal, not a config bug
When it happens
Trigger: fetch() requests `${FEED_BASE}?page=0` via fetchPageWithRetry with redirect:'error'; the returned JSON is falsy or first.results is not an Array — API outage, error payload, Cloudflare challenge with 200, or a Muse API schema change.
Common situations: The Muse API is down or returning a maintenance payload; an HTML bot-challenge page is served with status 200; the public API version was bumped and { results: [...] } became { data: [...] }; an invalid API key/plan producing an error JSON body.
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
- thehub: unexpected API response on page
- Apify did not return a run id
- getonbrd: unexpected API response for category
- glints: unexpected API response
- hackernews: unexpected item response for thread
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/67eff14619d53185.
Report an issue: GitHub.
Appendix: source
Thrown at providers/themuse.mjs:147
export default {
id: 'themuse',
async fetch(_entry, ctx) {
assertMuseUrl(FEED_BASE);
// Page 0 is fetched outside the tolerant loop below and its failure is
// NOT caught: a completely dead board must throw, not return []. A
// caught page-0 failure would return an empty array indistinguishable
// from a healthy "0 jobs today" result -- scan.mjs's consecutive-failure
// detector resets its streak on any non-throwing fetch, so a themuse
// outage would silently reset the very detector meant to catch it.
// Mirrors workday.mjs, which fetches its first page outside the
// retry-tolerant loop (`page = 1` start) for the same reason.
const firstUrl = `${FEED_BASE}?page=0`;
// redirect:'error' prevents SSRF via server-side redirects
const first = await fetchPageWithRetry(ctx, firstUrl, { redirect: 'error' });
if (!first || !Array.isArray(first.results)) {
throw new Error(
`themuse: unexpected API response on page 0 — expected { results: [...] }, got keys: [${first ? Object.keys(first).join(', ') : 'null'}]`,
);
}
const allResults = [...first.results];
const pageCount = Number.isInteger(first.page_count) && first.page_count > 1
? Math.min(first.page_count, MAX_PAGES)
: 1;
// Pages 1+ stay tolerant: a page that exhausts retries, OR comes back
// with an unexpected shape (a successful fetch, no retry involved --
// caught here so it lands in the same truncation path instead of
// escaping uncaught and discarding allResults), truncates with a warning
// and returns whatever was already gathered instead of discarding it.
for (let page = 1; page < pageCount; page++) {
await sleep(INTER_PAGE_DELAY_MS, ctx);
const url = `${FEED_BASE}?page=${page}`;
let json;
try {View on GitHub (pinned to aac998c7ed)