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

  1. Run 'trip search <name>' to find the exact Trip.com city name for --to
  2. Use the official English city name with correct spelling
  3. Catch ArgumentError and prompt the user to pick a city from search results
  4. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/22d8dea430c608d3. Report an issue: GitHub.