{"record":{"id":"5a1102de8713afb1","repo":"jackwener/OpenCLI","slug":"reuters-search-api-failed-status","errorCode":null,"errorMessage":"Reuters search API failed (${status})","messagePattern":"Reuters search API failed \\((.+?)\\)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/reuters/search.js","lineNumber":48,"sourceCode":"        await page.wait(2);\n        const result = await page.evaluate(buildSearchScript(query, limit));\n        if (result?.error) {\n            throw new CommandExecutionError(`Reuters search failed inside the page: ${result.error}`);\n        }\n        if (!result || typeof result !== 'object') {\n            throw new CommandExecutionError('Reuters search API returned an unreadable response');\n        }\n        if (isAuthStatus(result.status) || looksAuthWallText(result.textPreview)) {\n            throw new AuthRequiredError(\n                'www.reuters.com',\n                `Reuters search requires an accessible Reuters browser session or completed human verification${result.status ? ` (HTTP ${result.status})` : ''}`,\n            );\n        }\n        if (result.ok !== true) {\n            const status = Number.isFinite(result.status) && result.status > 0\n                ? `HTTP ${result.status}${result.statusText ? ` ${result.statusText}` : ''}`\n                : 'no upstream response';\n            throw new CommandExecutionError(`Reuters search API failed (${status})`);\n        }\n        if (!result.body) {\n            const detail = result.parseError ? `: ${result.parseError}` : '';\n            throw new CommandExecutionError(\n                `Reuters search returned a non-JSON body${detail}`,\n                'Open www.reuters.com in your browser and clear any challenge before retrying.',\n            );\n        }\n        const rows = mapSearchArticles(result.body, limit);\n        if (!rows.length) {\n            throw new EmptyResultError('reuters search', `No articles matched \"${query}\". Try broadening the query.`);\n        }\n        return rows;\n    },\n});\n","sourceCodeStart":30,"sourceCodeEnd":64,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reuters/search.js#L30-L64","documentation":"CommandExecutionError thrown when the in-page fetch completed but result.ok !== true, meaning the Reuters search API answered with a non-success response (or no upstream response at all). The message embeds 'HTTP <status>[ <statusText>]' when a status is available, or 'no upstream response' when the request never reached a server (network failure, blocked request, abort).","triggerScenarios":"result.ok is false because the articles-by-search-v2 fetch returned 4xx/5xx, was blocked by Datadome at the network layer, or the fetch rejected so no upstream response exists.","commonSituations":"Reuters API returning 5xx during incidents; rate limiting (429); Datadome blocking the request server-side; temporary network outage inside the browser tab; Reuters changing the endpoint path so it 404s.","solutions":["Re-run the command — transient 5xx or rate limiting often clears on retry (add a delay to avoid 429).","Check the reported HTTP status: 429 means slow down; 404 suggests Reuters changed the API path and the injected script needs updating.","Complete the Datadome challenge / refresh the session if the block is anti-bot related.","Verify network connectivity in the browser session (the 'no upstream response' case)."],"exampleFix":"// before: immediate retry hammering a 429\nfor (const q of queries) await cli.run('reuters search', { query: q });\n// after: backoff on failure\ntry {\n  const rows = await cli.run('reuters search', { query: q });\n} catch (e) {\n  if (/HTTP 429/.test(e.message)) await sleep(30000);\n}","handlingStrategy":"retry","validationCode":"// check reachability of the endpoint surface before batch calls\nconst res = await page.evaluate(() => fetch(location.origin, { method: 'HEAD' }).then(r => r.status).catch(() => 0));\nif (!res) throw new Error('No upstream connectivity from the browser session');","typeGuard":"function hasUpstreamFailure(result) {\n  return typeof result === 'object' && result !== null && result.ok !== true &&\n    (typeof result.status !== 'number' || result.status >= 400);\n}","tryCatchPattern":"try {\n  const rows = await cli.run('reuters search', { query });\n} catch (e) {\n  const m = e.message.match(/HTTP (\\d+)/);\n  if (!m) throw e;\n  const status = Number(m[1]);\n  if (status === 429 || status >= 500) {\n    await sleep(30_000);\n    return cli.run('reuters search', { query });\n  }\n  throw e;\n}","preventionTips":["Rate-limit batch searches; back off on 429.","Monitor Reuters status/incidents for 5xx windows.","Keep buildSearchScript in sync with the current articles-by-search-v2 endpoint path.","Confirm browser-session network access before large jobs."],"tags":["network","http-status","api","anti-bot"],"backgroundTag":"upstream-http-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}