{"record":{"id":"b179fec98dbd54a4","repo":"jackwener/OpenCLI","slug":"linkedin-connections-api-returned-an-unexpected-re","errorCode":null,"errorMessage":"LinkedIn connections API returned an unexpected response: ","messagePattern":"LinkedIn connections API returned an unexpected response: ","errorType":"error_code","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/connections.js","lineNumber":105,"sourceCode":"        const limit = parseLimit(kwargs.limit, 20, 500);\n        await page.goto('https://www.linkedin.com/mynetwork/invite-connect/connections/');\n        await page.wait(2);\n        await assertLinkedInAuthenticated(page, 'linkedin connections');\n        const csrf = await requireLinkedInCookie(page, 'linkedin connections');\n        const rows = [];\n        let start = 0;\n        while (rows.length < limit) {\n            const remaining = limit - rows.length;\n            const count = remaining < PAGE_SIZE ? remaining : PAGE_SIZE;\n            const url = `${CONNECTIONS_PATH}?start=${start}&count=${count}`;\n            const fetched = unwrapEvaluateResult(\n                await page.evaluate(`(${fetchConnections.toString()})(${JSON.stringify(url)}, ${JSON.stringify(csrf)})`),\n            );\n            if (fetched && fetched.authRequired) {\n                throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn connections API authentication failed: ' + fetched.error);\n            }\n            if (!fetched || fetched.error || !fetched.json) {\n                throw new CommandExecutionError('LinkedIn connections API returned an unexpected response: ' + ((fetched && fetched.error) || 'no data'));\n            }\n            const elements = fetched.json.elements;\n            if (!Array.isArray(elements)) {\n                throw new CommandExecutionError('LinkedIn connections API returned a malformed payload: missing elements array');\n            }\n            if (elements.length === 0) break;\n            for (const element of elements) {\n                rows.push(mapConnection(element, rows.length));\n                if (rows.length >= limit) break;\n            }\n            start += elements.length;\n            if (elements.length < count) break;\n        }\n        if (rows.length === 0) {\n            throw new EmptyResultError('linkedin connections', 'No LinkedIn connections were found.');\n        }\n        return rows;\n    },","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/connections.js#L87-L123","documentation":"If the Voyager connections fetch yields neither authRequired nor valid JSON (fetched falsy, fetched.error set, or fetched.json missing), the command throws CommandExecutionError with the underlying error string. It means the request completed abnormally but was not an authentication problem.","triggerScenarios":"fetchConnections returns { error: 'HTTP 429' } (rate limit), { error: 'HTTP 5xx' } (server error), { error: 'response was not valid JSON' }, or { error: 'fetch failed: ...' } from a network-level failure inside the page.","commonSituations":"LinkedIn rate-limiting aggressive pagination (HTTP 429); transient 5xx during a LinkedIn incident; page context destroyed mid-fetch (navigation/close) causing 'fetch failed'; corporate proxy intercepting the response.","solutions":["Read the appended cause in the message ('HTTP 429', 'fetch failed: ...') and address that specific condition.","If HTTP 429, wait several minutes and retry with a smaller --limit to reduce page count.","For HTTP 5xx, retry later or check linkedin.com status; it is server-side.","Retry once after reloading; transient in-page fetch failures usually clear on a fresh navigation."],"exampleFix":"// before (aggressive pagination)\n$ opencli linkedin connections --limit 500\nCommandExecutionError: LinkedIn connections API returned an unexpected response: HTTP 429\n// after\n$ opencli linkedin connections --limit 40  # fewer requests, spaced out","handlingStrategy":"retry","validationCode":"// No pre-call validation possible for transient HTTP failures; check connectivity first.\nif (!(await fetch('https://www.linkedin.com', { method: 'HEAD' })).ok) {\n  throw new Error('linkedin.com unreachable — fix network before calling connections.');\n}","typeGuard":"function isTransientHttpFailure(message) {\n  return /HTTP (429|5\\d\\d)|fetch failed/i.test(message || '');\n}","tryCatchPattern":"try {\n  const rows = await opencli.linkedin.connections({ limit: 20 });\n} catch (e) {\n  if (/unexpected response/.test(e.message || '')) {\n    if (/HTTP 429/.test(e.message)) await new Promise(r => setTimeout(r, 5 * 60_000));\n    return opencli.linkedin.connections({ limit: 20 }); // single retry\n  }\n  throw e;\n}","preventionTips":["Keep --limit modest so pagination stays under rate limits.","Space out repeated LinkedIn CLI calls; HTTP 429 means back off.","Re-check the appended cause string to pick the right remedy (429 vs 5xx vs fetch failed).","Avoid navigating away or closing the page while the fetch runs."],"tags":["linkedin","network","http-error"],"backgroundTag":"unexpected-api-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}