{"record":{"id":"d8334bd5f5930d7f","repo":"jackwener/OpenCLI","slug":"article-url-cannot-be-empty","errorCode":null,"errorMessage":"Article URL cannot be empty","messagePattern":"Article URL cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/reuters/article-detail.js","lineNumber":27,"sourceCode":"import { buildArticleDetailScript, mapArticleDetail } from './utils.js';\n\nconst REUTERS_HOST = /^https?:\\/\\/(?:www\\.)?reuters\\.com\\//i;\n\ncli({\n    site: 'reuters',\n    name: 'article-detail',\n    access: 'read',\n    description: 'Reuters 路透社文章详情：标题/作者/正文文本',\n    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            );","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reuters/article-detail.js#L9-L45","documentation":"The reuters article-detail command throws ArgumentError when the positional url argument is empty or whitespace after trimming. A URL is mandatory to know which article page to load, so the command fails fast with a validation error before any navigation.","triggerScenarios":"Invoking the command with no positional argument, an empty string, or a value consisting only of whitespace, e.g. `reuters article-detail \"\"` or omitting the URL entirely.","commonSituations":"Shell variables that expand to empty ($URL unset); misquoted arguments swallowed by the shell; automation pipelines passing an empty field from upstream data.","solutions":["Pass the Reuters article URL as the positional argument","Verify the shell variable holding the URL is actually set and non-empty","Quote the URL to prevent the shell from splitting or dropping it"],"exampleFix":"// before\nreuters article-detail \"$ARTICLE_URL\"   # ARTICLE_URL unset -> ArgumentError\n// after\n: \"${ARTICLE_URL:?must be set}\"\nreuters article-detail \"$ARTICLE_URL\"","handlingStrategy":"validation","validationCode":"const url = (process.argv[2] || '').trim();\nif (!url) { console.error('usage: reuters article-detail <reuters.com url>'); process.exit(1); }","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Validate URL arguments are non-empty before invoking","Use ${VAR:?unset} shell guards for variables","Quote positional args in scripts","Fail fast with a usage message in wrappers"],"tags":["validation","argument-error","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}