jackwener/OpenCLI · info · EmptyResultError

dianping ${contextHint}

Error message

dianping ${contextHint}

What it means

The final fallback of detectAuthOrPageFailure: when the page matched neither captcha nor login patterns and none of the caller-supplied emptyPatterns matched, it throws EmptyResultError('dianping <contextHint>') if an empty pattern did match, and otherwise CommandExecutionError 'did not render expected data'. EmptyResultError here means the page genuinely rendered but contained no matching data — dianping returned an empty result set for the query.

Source

Thrown at clis/dianping/utils.js:119

 * redirects to verify.meituan.com (Yoda icon-tap captcha) or to a login
 * page when the cookie is missing.
 */
export function detectAuthOrPageFailure({ text = '', url = '' }, contextHint, { emptyPatterns = [] } = {}) {
    const signal = `${url} ${text}`;
    if (/verify\.meituan\.com|verifyimg|身份核实|请依次点击|美团安全验证|Yoda/i.test(signal)) {
        throw new AuthRequiredError(
            'dianping.com',
            `dianping ${contextHint} blocked by captcha — open ${url || 'www.dianping.com'} manually in this profile and solve the captcha, then retry`,
        );
    }
    if (/login\.dianping\.com|account\.dianping\.com|请先登录|未登录|请登录/.test(signal)) {
        throw new AuthRequiredError(
            'dianping.com',
            `dianping ${contextHint} requires login — sign in to dianping.com in this profile, then retry`,
        );
    }
    if (emptyPatterns.some((pattern) => pattern.test(signal))) {
        throw new EmptyResultError(`dianping ${contextHint}`);
    }
    const sample = text ? `; sample: ${String(text).slice(0, 160)}` : '';
    throw new CommandExecutionError(
        `dianping ${contextHint} did not render expected data${sample}`,
        'This usually means dianping changed its HTML, returned an unexpected error page, or the browser profile hit an unrecognized anti-bot state.',
    );
}

/**
 * Parse "21231" / "1.2万" review-count strings into integers.
 * Returns null when the input has no parseable digits.
 */
export function parseReviewCount(raw) {
    if (raw == null) return null;
    const s = String(raw).trim();
    if (!s) return null;
    const wanMatch = s.match(/^([\d.]+)\s*万/);
    if (wanMatch) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Broaden the search keyword or remove filters and retry.
  2. Check the cityId: resolveCityId maps names to ids; try the shop's actual city or omit it to use the cookie's default city.
  3. Verify the shop id still exists by opening www.dianping.com/shop/<id> in a browser.
  4. Treat it as an expected empty result if your query is legitimately unmatched — the CLI throws EmptyResultError so scripts can skip it (catch and continue).

Example fix

// before
await search({ city: 'xiamen', keyword: 'deep dish pizza' }); // EmptyResultError
// after
try {
  await search({ city: 'xiamen', keyword: 'pizza' });
} catch (err) {
  if (err.code === 'EMPTY_RESULT') return []; // expected: no matches
  throw err;
}
Defensive patterns

Strategy: fallback

Type guard

function isEmptyResultError(err) {
  return err instanceof Error && err.code === 'EMPTY_RESULT';
}

Try / catch

try {
  results = await dianpingSearch(args);
} catch (err) {
  if (err.code === 'EMPTY_RESULT') {
    results = []; // expected: no data for this query
  } else throw err;
}

Prevention

When it happens

Trigger: A dianping search/detail step whose rendered HTML matches one of the emptyPatterns regexes passed by the adapter — e.g. searching a keyword with zero shops in the chosen city, a category filter with no matches, or a deleted/closed shop page.

Common situations: Overly narrow search keywords, mismatched cityId vs keyword (shops only exist in another city), filters (price/cuisine/district) that exclude all results, or a shop that has closed since the id was collected.

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