jackwener/OpenCLI · warning · EmptyResultError

google-scholar/search

google-scholar/search

Error message

Try a different query or check whether Google Scholar returned a CAPTCHA.

What it means

EmptyResultError (code `google-scholar/search`) thrown when the Scholar search page legitimately contains zero result cards: no items were extracted AND `resultCount` is 0. The hint tells the user the query simply matched nothing, or Scholar served a CAPTCHA instead of results.

Source

Thrown at clis/google-scholar/search.js:69

            authors: authors.slice(0, 80),
            source: source.slice(0, 60),
            year,
            cited,
            url,
          });
          if (results.length >= ${limit}) break;
        }
        return { items: results, resultCount: resultCards.length };
      })()
    `);
        if (!wrapper || typeof wrapper !== 'object' || !Array.isArray(wrapper.items)) {
            throw new CommandExecutionError('Google Scholar search returned an unexpected payload shape');
        }
        if (wrapper.items.length === 0) {
            if (Number(wrapper.resultCount) > 0) {
                throw new CommandExecutionError('Google Scholar result cards were present but no rows could be extracted');
            }
            throw new EmptyResultError('google-scholar/search', 'Try a different query or check whether Google Scholar returned a CAPTCHA.');
        }
        return wrapper.items;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Broaden or rephrase the query and re-run.
  2. Check whether scholar.google.com in a browser shows a CAPTCHA; if so, wait or switch IP/network.
  3. Slow down request frequency if looping over many queries.
  4. Handle EmptyResultError in your pipeline as a normal no-results case.

Example fix

// before
opencli run google-scholar search "asdf qwerty zzz"
// after
opencli run google-scholar search "transformer attention is all you need"
Defensive patterns

Strategy: try-catch

Validate before calling

if (!query || query.trim().length < 3) {
  console.warn('Query too narrow; EmptyResultError likely.');
}

Try / catch

try {
  return await run('google-scholar search', query);
} catch (e) {
  if (e.name === 'EmptyResultError') return []; // expected: no matches or CAPTCHA
  throw e;
}

Prevention

When it happens

Trigger: Calling `google-scholar search <query>` with a query that has no Scholar matches, or when the results page was replaced by a CAPTCHA/'unusual traffic' page so no `.gs_r.gs_or.gs_scl` cards exist at all.

Common situations: Overly narrow or malformed queries; heavy scraping triggering CAPTCHA walls; VPN/datacenter IPs flagged by Google; new papers not yet indexed.

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/b2912bca71ba824f. Report an issue: GitHub.