{"record":{"id":"285d597d436c630d","repo":"jackwener/OpenCLI","slug":"reuters-article-detail-failed-inside-the-page-r","errorCode":null,"errorMessage":"Reuters article-detail failed inside the page: ${result.error}","messagePattern":"Reuters article-detail failed inside the page: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/reuters/article-detail.js","lineNumber":36,"sourceCode":"    domain: 'www.reuters.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'url', required: true, positional: true, help: 'Reuters article URL (must be on reuters.com)' },\n    ],\n    columns: ['title', 'date', 'section', 'section_path', 'authors', 'description', 'word_count', 'url', 'body'],\n    func: async (page, kwargs) => {\n        const url = String(kwargs.url || '').trim();\n        if (!url) {\n            throw new ArgumentError('Article URL cannot be empty');\n        }\n        if (!REUTERS_HOST.test(url)) {\n            throw new ArgumentError(`URL must be on reuters.com, got ${url}`);\n        }\n        await page.goto(url);\n        await page.wait(2);\n        const result = await page.evaluate(buildArticleDetailScript());\n        if (result?.error) {\n            throw new CommandExecutionError(`Reuters article-detail failed inside the page: ${result.error}`);\n        }\n        if (result?.authRequired) {\n            throw new AuthRequiredError('www.reuters.com', 'Reuters article-detail is gated by login, subscription, or human verification');\n        }\n        if (!result || result.ok !== true) {\n            throw new CommandExecutionError(\n                'Reuters article-detail returned no payload',\n                'Check that the URL points to a Reuters article and that the page loaded',\n            );\n        }\n        const detail = mapArticleDetail(result.body?.article, result.body?.bodyText, url);\n        if (!detail || (!detail.title && !detail.body)) {\n            throw new EmptyResultError('reuters article-detail', 'Page rendered no article body — likely paywalled or a non-article URL');\n        }\n        return [detail];\n    },\n});\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reuters/article-detail.js#L18-L54","documentation":"The command throws CommandExecutionError when the in-page scraping script invoked via buildArticleDetailScript returns { error } — i.e. the injected browser-side extraction failed. This isolates failures inside the rendered page (selectors missing, script exception) from navigation failures.","triggerScenarios":"page.evaluate runs the detail script but it returns result.error truthy — typically because the loaded page lacks expected Reuters DOM structure or an in-page exception occurred while parsing article JSON/DOM.","commonSituations":"Reuters changed its page markup/JSON schema; a consent or bot-check page rendered instead of the article; the URL points to a non-article reuters.com page (section page, author profile) whose structure the script cannot parse.","solutions":["Retry — transient interstitials often clear on a second load","Verify the URL is a real article page, not a section or profile page","Update the tool / report a bug if Reuters changed their page structure","Check for bot-detection/consent pages and use an authenticated session if needed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await reutersArticleDetail(url);\n} catch (e) {\n  if (String(e.message).startsWith('Reuters article-detail failed inside the page')) {\n    // in-page scrape failure: retry once, then report as likely markup change\n    return await retryOnce(url);\n  }\n  throw e;\n}","preventionTips":["Only pass direct article permalinks","Retry transient in-page failures once","Pin tool versions and update when Reuters markup changes","Distinguish non-article URLs (sections, profiles) before calling"],"tags":["scraping","browser","dom"],"backgroundTag":"page-scrape-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}