jackwener/OpenCLI · warning · EmptyResultError

google images

google images

Error message

No Google image results matched "${query}".

What it means

EmptyResultError (code `google images`) thrown by `normalizeImageRows` when every raw row was filtered out (or none were provided), leaving `rows.length === 0` after slicing to the limit. The command guarantees at least one result or raises this user-facing message including the query.

Source

Thrown at clis/google/images.js:378

        if (!imageUrl || !sourceUrl || isGoogleInternalResultUrl(sourceUrl)) {
            throw new CommandExecutionError('google images returned a result row without stable external image/source identity.');
        }
        const source = String(row[4] || '').trim() || new URL(sourceUrl).hostname.replace(/^www\./, '');
        const title = String(row[0] || '').trim() || source;
        return {
            rank: index + 1,
            title,
            imageUrl,
            thumbnailUrl,
            sourceUrl,
            source,
            width: Number.isFinite(Number(row[5])) ? Number(row[5]) : null,
            height: Number.isFinite(Number(row[6])) ? Number(row[6]) : null,
        };
    });

    if (rows.length === 0) {
        throw new EmptyResultError('google images', `No Google image results matched "${query}".`);
    }
    return rows;
}

async function evaluateGoogleImagesPageState(page) {
    const raw = await page.evaluate(inspectGoogleImagesPage);
    const state = unwrapBrowserResult(raw);
    if (!state || typeof state !== 'object' || Array.isArray(state)) {
        throw new CommandExecutionError('google images returned an unexpected page-state payload shape.');
    }
    return state;
}

async function evaluateGoogleImageRows(page, limit, resolveOriginal) {
    let rows = [];
    for (let attempt = 0; attempt < 6; attempt += 1) {
        const raw = await page.evaluate(extractGoogleImageRows, limit, resolveOriginal);
        rows = requireRows(raw, 'google images');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Rephrase or broaden the query and re-run.
  2. Retry after a delay if the page may have been slow to render.
  3. Check a browser for the same query — if a CAPTCHA/consent page appears, resolve it or change IP/locale.
  4. Handle EmptyResultError as a normal no-results outcome in your pipeline.

Example fix

// before
opencli run google images "qzxv nonexisting thing 12345"
// after
opencli run google images "golden retriever puppy"
Defensive patterns

Strategy: try-catch

Validate before calling

if (!query || query.trim().length === 0) {
  console.warn('Empty query will yield EmptyResultError from google images.');
}

Try / catch

try {
  rows = await run('google images', query);
} catch (e) {
  if (e.name === 'EmptyResultError') return []; // no image matches
  throw e;
}

Prevention

When it happens

Trigger: Calling `google images <query>` where the page extraction returned zero usable rows: the query genuinely has no image matches, the results hadn't rendered when the script ran, or all candidate rows failed the shape/URL filters (errors 1616/1617 were per-row fatal; here rows can also be absent entirely).

Common situations: Very obscure or nonsense queries; safe-search filtering out all results; slow network where images grid hasn't painted; Google serving a CAPTCHA/consent page with no image grid.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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