jackwener/OpenCLI · error · ArgumentError

URL must be on reuters.com, got ${url}

Error message

URL must be on reuters.com, got ${url}

What it means

The reuters article-detail command throws ArgumentError when the supplied URL does not match REUTERS_HOST, i.e. it is not a reuters.com URL. The command scrapes Reuters pages and only supports reuters.com, so off-site URLs are rejected up front.

Source

Thrown at clis/reuters/article-detail.js:30

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',
            );
        }
        const detail = mapArticleDetail(result.body?.article, result.body?.bodyText, url);
        if (!detail || (!detail.title && !detail.body)) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use the canonical www.reuters.com article URL
  2. Resolve shorteners/redirects to their final reuters.com destination first
  3. Check the URL for typos in the hostname
  4. If the article only exists off-site, this command cannot fetch it — use a source-appropriate tool

Example fix

// before
reuters article-detail "https://news.google.com/rss/articles/CBM..."
// after
reuters article-detail "https://www.reuters.com/world/us/some-article-2026-01-01/"
Defensive patterns

Strategy: validation

Validate before calling

try {
  const u = new URL(input);
  if (!/(^|\.)reuters\.com$/.test(u.hostname)) throw new Error('not a reuters.com URL: ' + input);
} catch { throw new Error('invalid URL: ' + input); }

Type guard

function isReutersUrl(u) {
  try { return new URL(u).hostname.endsWith('reuters.com'); } catch { return false; }
}

Try / catch

null

Prevention

When it happens

Trigger: Passing a URL on another domain (e.g. reuters.org, a Google News redirect, an archive mirror) or a misspelled host, so the REUTERS_HOST regex test fails.

Common situations: Using a shortened or redirected link that resolves off reuters.com; copying an AMP or third-party syndicated copy of the article; typos like 'reuterss.com'; passing a search-results page from another site.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/3b7029b40842bc40. Report an issue: GitHub.