jackwener/OpenCLI · error · CommandExecutionError
dianping ${contextHint} did not render expected data${sample
Error message
dianping ${contextHint} did not render expected data${sample} What it means
detectAuthOrPageFailure is the dianping CLI's guard against pages that loaded but contain no recognizable data. After the page text fails the emptyPatterns check (EmptyResultError), it throws CommandExecutionError meaning the page rendered something, but not the expected content — typically a layout change, an error page, or an unrecognized anti-bot/captcha state. The message includes a 160-char sample of the page text to help diagnose what actually rendered.
Source
Thrown at clis/dianping/utils.js:122
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) {
const n = Number(wanMatch[1]);
return Number.isFinite(n) ? Math.round(n * 10000) : null;
}View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the '; sample:' portion of the message to see what actually rendered (captcha, login wall, redesign).
- Open the browser profile manually, complete any captcha/login, and retry so the profile has valid session state.
- Update the CLI's selectors/emptyPatterns to match dianping's current markup if the site changed.
- Retry later or from a different network/IP if the sample shows an anti-bot or rate-limit page.
- Run the command non-headless (visible browser) to interactively pass challenges.
Example fix
// before: blindly retrying the same command
await cli.run('dianping shop 12345');
// after: check sample text / refresh profile state first
try {
await cli.run('dianping shop 12345');
} catch (e) {
if (e instanceof CommandExecutionError && /sample:/.test(e.message)) {
await refreshBrowserProfile(); // re-login / solve captcha manually
await cli.run('dianping shop 12345');
}
} Defensive patterns
Strategy: try-catch
Validate before calling
// check page state before re-running
const text = await page.evaluate('document.body.innerText');
if (/captcha|verify|log in|access denied/i.test(text)) await resolveAntiBotManually(); Type guard
function looksLikeCaptcha(text) {
return /captcha|verify you are human|access denied|异常|验证/i.test(text);
} Try / catch
try {
await runDianpingCommand(args);
} catch (e) {
if (/did not render expected data/.test(e.message)) {
const sample = e.message.split('sample:')[1] || '';
console.error('Page rendered unexpected content:', sample);
// refresh profile/login then retry once
}
} Prevention
- Keep the browser profile logged in and captcha-free by using it interactively periodically.
- Log the sample text from every failure to spot dianping redesigns early.
- Keep selectors/emptyPatterns updated after Discord/dianping UI changes.
- Add backoff between requests to avoid anti-bot flagging.
- Run non-headless first when a new site layout is suspected.
When it happens
Trigger: Calling a dianping CLI command when the page HTML no longer matches expected selectors/patterns: dianping ships a DOM redesign, the browser profile is flagged and served an interstitial challenge not covered by emptyPatterns, a soft error page (rate-limit, login wall) renders, or the network returned truncated content.
Common situations: Dianping frontend update breaks selectors; scraping from an IP flagged by anti-bot; stale/expired cookies in the persistent browser profile; running headless with a profile that gets served a verification page.
Related errors
- Failed to fetch Barchart greeks for ${symbol}
- Failed to extract Booking.com cards: ${err?.message || err}
- Booking.com page returned no extractable data
- Booking.com extractor returned an invalid status
- Booking.com extractor returned malformed items
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/2513458a68b5c38f.
Report an issue: GitHub.