jackwener/OpenCLI · warning · EmptyResultError
ctrip search
Error message
ctrip search
What it means
An EmptyResultError thrown by `ctrip search` when Ctrip's suggest API returned data, but after filtering and mapping (mapSuggestRow), no row had a usable `name` — i.e. the search keyword matched nothing usable. The message suggests trying a destination, scenic spot, or landmark keyword such as 苏州 or 故宫.
Source
Thrown at clis/ctrip/search.js:37
columns: [
'rank', 'id', 'type', 'displayType', 'name', 'eName',
'cityId', 'cityName', 'provinceName', 'countryName',
'lat', 'lon', 'score', 'url',
],
func: async (kwargs) => {
const query = String(kwargs.query || '').trim();
if (!query) {
throw new ArgumentError('Search keyword cannot be empty');
}
const limit = parseLimit(kwargs.limit);
const raw = await fetchSuggest(query, 'D');
const rows = raw
.filter((item) => !!item && typeof item === 'object')
.slice(0, limit)
.map(mapSuggestRow)
.filter((row) => row.name);
if (!rows.length) {
throw new EmptyResultError('ctrip search', 'Try a destination, scenic spot, or landmark keyword such as "苏州" or "故宫"');
}
return rows;
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry with a well-known Chinese destination keyword such as 苏州, 故宫, or 三亚
- Use the destination's Chinese name rather than pinyin/English
- Shorten the query to the city or landmark core (e.g. 马尔代夫 instead of 马尔代夫某岛)
- Catch EmptyResultError and fall back to a broader keyword in your script
Example fix
// before
const rows = await runCli('ctrip', 'search', keyword); // throws when empty
// after
let rows;
try {
rows = await runCli('ctrip', 'search', keyword);
} catch (e) {
if (e.name === 'EmptyResultError') rows = await runCli('ctrip', 'search', fallbackKeyword);
else throw e;
} Defensive patterns
Strategy: fallback
Validate before calling
const KNOWN = ['苏州','北京','三亚','故宫','马尔代夫'];
if (!q || q.length < 2) console.warn('keyword may not match Ctrip suggest; consider a known destination'); Try / catch
try {
const rows = await runCli('ctrip', 'search', keyword);
} catch (e) {
if (e.name === 'EmptyResultError') {
const rows2 = await runCli('ctrip', 'search', broaderKeyword);
} else throw e;
} Prevention
- Prefer Chinese destination/landmark keywords over pinyin or English
- Shorten queries to the city or landmark core
- Keep a curated fallback-keyword list for your use case
- Treat EmptyResultError as data-absent, not a bug
When it happens
Trigger: Calling `opencli ctrip search <keyword>` where fetchSuggest(query, 'D') returns rows that are all non-objects, filtered out, or map to rows without a name — e.g. misspelled place names, single Latin letters, brand names, or extremely obscure keywords Ctrip's destination suggest does not know.
Common situations: Typo'd or romanized keywords ("sanya" instead of 三亚); searching for hotels or restaurants rather than destinations; keywords in a language Ctrip suggest does not index; overly specific multi-word queries.
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
- No tour packages for "${destination}"
- Ctrip attraction links rendered but parser did not find requ
- No coaches for ${fromCity} to ${toCity} on ${date}
- No sailings for ${fromCity} to ${toCity} on ${date}
- ctrip flight-round
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f91c04214f632ae2.
Report an issue: GitHub.