{"record":{"id":"d4a22be8ece7f88c","repo":"santifer/career-ops","slug":"getonbrd-unexpected-api-response-for-category","errorCode":null,"errorMessage":"getonbrd: unexpected API response for category \"${category}\" on page ${page} — expected { data: [...] }, got keys: [${json ? Object.keys(json).join(', ') : 'null'}]","messagePattern":"getonbrd: unexpected API response for category \"(.+?)\" on page (.+?) — expected (.+?), got keys: \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"providers/getonbrd.mjs","lineNumber":182,"sourceCode":"\n  async fetch(entry, ctx) {\n    const categories = resolveCategories(entry);\n    const maxPages = resolveMaxPages(entry);\n    const fallbackCompany = entry?.name;\n    const out = [];\n    // A posting can appear under several categories; first sighting wins so the\n    // scanner never sees the same URL twice from one entry.\n    const seen = new Set();\n\n    for (const category of categories) {\n      const base = assertGetonbrdUrl(feedBase(category));\n\n      for (let page = 1; page <= maxPages; page++) {\n        const url = `${base}?per_page=${PER_PAGE}&expand[]=company&page=${page}`;\n        // redirect:'error' prevents SSRF via server-side redirects\n        const json = await ctx.fetchJson(url, { redirect: 'error' });\n        if (!json || !Array.isArray(json.data)) {\n          throw new Error(\n            `getonbrd: unexpected API response for category \"${category}\" on page ${page} — expected { data: [...] }, got keys: [${json ? Object.keys(json).join(', ') : 'null'}]`,\n          );\n        }\n        for (const j of json.data) {\n          const normalized = normalizeGetonbrdJob(j, fallbackCompany);\n          if (!normalized || seen.has(normalized.url)) continue;\n          seen.add(normalized.url);\n          out.push(normalized);\n        }\n        if (json.data.length < PER_PAGE) break; // short page → last page reached\n      }\n    }\n    return out;\n  },\n};\n","sourceCodeStart":164,"sourceCodeEnd":198,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/getonbrd.mjs#L164-L198","documentation":"The getonbrd provider's fetch loop calls the public JSON:API feed (categories/{slug}/jobs?per_page=100&expand[]=company&page=N) with redirect:'error'. It requires the response JSON to have a data array; if the parsed body is null or lacks Array.isArray(json.data), it throws this error naming the category, page, and the actual top-level keys received. It signals the API responded successfully but with an unexpected shape.","triggerScenarios":"The Get on Board API returns a non-feed payload — e.g. an error object {error: ...}, an HTML error page that still parsed as JSON oddly, a rate-limit JSON body, or an API version change reshaping the response — on any page of a category feed fetch.","commonSituations":"Get on Board changes their API schema; a category slug resolves but the endpoint returns a 200 with an error envelope; a proxy/WAF returns a JSON error body; per_page/page params stop being honored.","solutions":["Log or inspect the raw response body for the failing URL (category + page are in the message) to see what keys came back","Verify the category slug is valid — try https://www.getonbrd.com/api/v0/categories/{slug}/jobs in a browser or curl","Check getonbrd.com API docs/changelog for a response-shape change and update normalizeGetonbrdJob/the provider accordingly","A proxy or captive portal in the environment may be intercepting the request — test from another network"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate the endpoint before a full run:\nconst res = await fetch('https://www.getonbrd.com/api/v0/categories/programming/jobs?per_page=1&page=1');\nconst j = await res.json();\nif (!j || !Array.isArray(j.data)) throw new Error('getonbrd feed shape changed — data[] missing');","typeGuard":"function isGetonbrdFeed(json) { return json != null && typeof json === 'object' && Array.isArray(json.data); }","tryCatchPattern":"try {\n  const json = await ctx.fetchJson(url, { redirect: 'error' });\n  if (!isGetonbrdFeed(json)) throw new Error(`getonbrd: unexpected shape, keys: ${Object.keys(json ?? {}).join(',')}`);\n} catch (e) {\n  console.error(`Category ${category} page ${page} failed: ${e.message} — inspect raw body and check for API schema changes`);\n  break; // skip this category, continue scanning others\n}","preventionTips":["Pin the API docs/changelog for getonbrd.com and re-verify feed shape after provider updates","Test category slugs with curl before adding them to portals.yml","Treat 200-with-error-body as a real possibility behind proxies/WAFs and log raw bodies on mismatch"],"tags":["api","response-shape","getonbrd","unexpected-response"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}