jackwener/OpenCLI · error · ArgumentError
Could not resolve destination "${to}" to a Trip.com city; ru
Error message
Could not resolve destination "${to}" to a Trip.com city; run 'trip search ${to}' to find the name What it means
Identical to the origin failure but for the --to keyword: resolvePackageCity(to) found no matching Trip.com city, so an ArgumentError is thrown advising 'trip search <to>' to locate the proper name. No network package search is attempted.
Source
Thrown at clis/trip/package.js:67
],
func: async (kwargs) => {
const from = parseKeyword('from', kwargs.from);
const to = parseKeyword('to', kwargs.to);
const depart = parseIsoDate('depart', kwargs.depart);
const ret = parseIsoDate('return', kwargs.return);
if (depart >= ret) {
throw new ArgumentError(`--depart must be before --return (got ${depart} .. ${ret})`);
}
const adults = parseAdults(kwargs.adults);
const limit = parseListLimit(kwargs.limit);
const origin = await resolvePackageCity(from);
if (!origin) {
throw new ArgumentError(`Could not resolve origin "${from}" to a Trip.com city; run 'trip search ${from}' to find the name`);
}
const dest = await resolvePackageCity(to);
if (!dest) {
throw new ArgumentError(`Could not resolve destination "${to}" to a Trip.com city; run 'trip search ${to}' to find the name`);
}
if (origin.cityId === dest.cityId) {
throw new ArgumentError(`--from and --to must differ (both resolved to ${dest.name})`);
}
const groups = await fetchPackageSearch({
dcode: origin.cityCode,
acode: dest.cityCode,
hcityid: String(dest.cityId),
depart,
ret,
adults,
});
if (groups.length === 0) {
throw new EmptyResultError('trip package', `No flight+hotel packages for ${origin.name} to ${dest.name} on ${depart} .. ${ret}`);
}
const rows = groups
.filter((g) => g && Array.isArray(g.flightlist) && g.flightlist.length)View on GitHub (pinned to 49907e53dc)
Solutions
- Run 'trip search <name>' to find the exact Trip.com city name for --to
- Use the official English city name with correct spelling
- Catch ArgumentError and prompt the user to pick a city from search results
- Store Trip.com city ids/names from earlier resolutions and reuse them
Example fix
// before --to "NRT" // airport code, unresolved // after --to "Tokyo" // resolved via 'trip search Tokyo'
Defensive patterns
Strategy: validation
Validate before calling
const dest = await resolvePackageCity(to);
if (!dest) {
throw new Error(`Destination "${to}" not found — run 'trip search ${to}' first`);
} Try / catch
try {
await tripPackageSearch({ from, to });
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('Could not resolve destination')) {
const matches = await tripCitySearch(to);
throw new UserInputError(`Unknown destination. Did you mean: ${matches.map(m => m.name).join(', ')}?`);
}
throw e;
} Prevention
- Validate the destination with 'trip search' before running the package query
- Use Trip.com's canonical city names, not codes or place aliases
- Present search suggestions to users when a destination fails to resolve
- Persist resolved destination names to avoid repeated lookup failures
When it happens
Trigger: --to holds a name absent from Trip.com's city index — misspellings, non-city place names (landmarks, airports), regional names Trip.com doesn't map, or unresolved transliterations.
Common situations: Reusing destination strings from other travel APIs, typing local-language names where Trip.com expects English (or vice versa), or truncated strings from UI autocomplete.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- Could not resolve origin "${from}" to a Trip.com city; run '
- --from and --to must differ (both resolved to ${dest.name})
- ${label} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/22d8dea430c608d3.
Report an issue: GitHub.