jackwener/OpenCLI · error · CommandExecutionError
dianping could not resolve cityId for '${cityArg}' (pinyin=$
Error message
dianping could not resolve cityId for '${cityArg}' (pinyin=${pinyin}); the city page rendered without a /search/keyword/{id}/ link What it means
CommandExecutionError thrown after a valid pinyin slug was derived but fetchCityIdByPinyin could not extract a numeric cityId: the city page (www.dianping.com/<pinyin>/) rendered without any /search/keyword/{id}/ link to scrape the id from. The name was accepted; the runtime resolution against the live site failed.
Source
Thrown at clis/dianping/cityResolver.js:93
const known = Object.keys(CITY_ID).filter((k) => /^[a-z]+$/.test(k)).join(', ');
throw new ArgumentError(
'city',
`unknown city '${cityArg}'. pass a numeric cityId, a pinyin slug (e.g. shantou), `
+ `a Chinese name listed on dianping.com/citylist, or one of: ${known}`,
);
}
} else {
const known = Object.keys(CITY_ID).filter((k) => /^[a-z]+$/.test(k)).join(', ');
throw new ArgumentError(
'city',
`unknown city '${cityArg}'. pass a numeric cityId, a pinyin slug (e.g. shantou), `
+ `a Chinese name listed on dianping.com/citylist, or one of: ${known}`,
);
}
const cityId = await fetchCityIdByPinyin(page, pinyin);
if (!cityId) {
throw new CommandExecutionError(
`dianping could not resolve cityId for '${cityArg}' (pinyin=${pinyin}); `
+ `the city page rendered without a /search/keyword/{id}/ link`,
);
}
RESOLVE_CACHE.set(lowered, cityId);
RESOLVE_CACHE.set(pinyin, cityId);
if (CHINESE_RE.test(raw)) RESOLVE_CACHE.set(raw, cityId);
return cityId;
}
/**
* Read https://www.dianping.com/citylist and return a Chinese-name → pinyin
* slug map for every city link present on the page. Used when the user
* supplied a Chinese name that isn't in the static map.
*/
async function lookupPinyinFromCitylist(page, chineseName) {
await page.goto('https://www.dianping.com/citylist');View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the pinyin slug is a real Dianping city (open https://www.dianping.com/<slug>/ in a browser and check for the search link).
- Use the numeric cityId directly to bypass online resolution, e.g. city=108.
- Retry later or from a cleaner session — anti-bot/captcha pages can hide the search link.
- If the site layout changed, update fetchCityIdByPinyin's selector to scrape the cityId from the new markup.
Example fix
// before
await cli.dianping.search({ keyword: '火锅', city: 'shantou' }); // transient scrape failure
// after
try { await cli.dianping.search({ keyword: '火锅', city: 'shantou' }); }
catch (e) { if (/could not resolve cityId/.test(e.message)) return cli.dianping.search({ keyword: '火锅', city: '108' }); throw e; } Defensive patterns
Strategy: fallback
Validate before calling
// check the city page resolves before the real call
await page.goto(`https://www.dianping.com/${slug}/`);
const ok = await page.evaluate(`!!document.querySelector('a[href*="/search/keyword/"]')`); Try / catch
try { return await searchWithCity(slug); }
catch (e) { if (/could not resolve cityId/.test(e.message)) { return searchWithCity(FALLBACK_CITY_ID); } throw e; } Prevention
- Cache successfully resolved cityIds (the library's RESOLVE_CACHE does this per-run) and persist them.
- Prefer hardcoded numeric cityIds for cities you query often.
- Detect captcha/verify pages and back off instead of hammering resolution.
- Verify slugs against dianping.com/citylist once and keep the mapping.
When it happens
Trigger: resolveCityIdAsync calls fetchCityIdByPinyin(page, pinyin); navigation to the city page succeeds but no anchor matching /search/keyword/\d+/ appears — unknown pinyin slug with no Dianping city page, blocked/challenge page, or layout change.
Common situations: Made-up or misspelled pinyin slug with no corresponding Dianping city page; Dianping serving a captcha/verify page instead of the city page; Dianping markup change removing the /search/keyword/{id}/ link; regional redirect to a default city without that link.
Related errors
- 1point3acres request failed: ${error?.message || error}
- 1point3acres request failed: HTTP ${res.status} ${res.status
- Barchart greeks request failed: HTTP ${data.status}${data.st
- Dianping member page rendered but no user_id link found — st
- unknown city '${cityArg}'. pass a numeric cityId, a pinyin s
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f62818b0dde60422.
Report an issue: GitHub.