jackwener/OpenCLI · error · ArgumentError
Article URL cannot be empty
Error message
Article URL cannot be empty
What it means
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.
Source
Thrown at clis/reuters/article-detail.js:27
import { buildArticleDetailScript, mapArticleDetail } from './utils.js';
const REUTERS_HOST = /^https?:\/\/(?:www\.)?reuters\.com\//i;
cli({
site: 'reuters',
name: 'article-detail',
access: 'read',
description: 'Reuters 路透社文章详情:标题/作者/正文文本',
domain: 'www.reuters.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'url', required: true, positional: true, help: 'Reuters article URL (must be on reuters.com)' },
],
columns: ['title', 'date', 'section', 'section_path', 'authors', 'description', 'word_count', 'url', 'body'],
func: async (page, kwargs) => {
const url = String(kwargs.url || '').trim();
if (!url) {
throw new ArgumentError('Article URL cannot be empty');
}
if (!REUTERS_HOST.test(url)) {
throw new ArgumentError(`URL must be on reuters.com, got ${url}`);
}
await page.goto(url);
await page.wait(2);
const result = await page.evaluate(buildArticleDetailScript());
if (result?.error) {
throw new CommandExecutionError(`Reuters article-detail failed inside the page: ${result.error}`);
}
if (result?.authRequired) {
throw new AuthRequiredError('www.reuters.com', 'Reuters article-detail is gated by login, subscription, or human verification');
}
if (!result || result.ok !== true) {
throw new CommandExecutionError(
'Reuters article-detail returned no payload',
'Check that the URL points to a Reuters article and that the page loaded',
);View on GitHub (pinned to 49907e53dc)
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
Example fix
// before
reuters article-detail "$ARTICLE_URL" # ARTICLE_URL unset -> ArgumentError
// after
: "${ARTICLE_URL:?must be set}"
reuters article-detail "$ARTICLE_URL" Defensive patterns
Strategy: validation
Validate before calling
const url = (process.argv[2] || '').trim();
if (!url) { console.error('usage: reuters article-detail <reuters.com url>'); process.exit(1); } Type guard
null
Try / catch
null
Prevention
- 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
When it happens
Trigger: 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.
Common situations: Shell variables that expand to empty ($URL unset); misquoted arguments swallowed by the shell; automation pipelines passing an empty field from upstream data.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
- archive search limit must be <= 100
- archive search query must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d8334bd5f5930d7f.
Report an issue: GitHub.