jackwener/OpenCLI · error · ArgumentError

Could not resolve origin "${from}" to a Trip.com city; run '

Error message

Could not resolve origin "${from}" to a Trip.com city; run 'trip search ${from}' to find the name

What it means

resolvePackageCity(from) returned falsy, meaning the --from keyword could not be matched to any Trip.com city. The library throws this ArgumentError and explicitly suggests running 'trip search <from>' to discover the correct city name.

Source

Thrown at clis/trip/package.js:63

        'from', 'to',
        'departure', 'arrival',
        'stops',
        'price', 'currency',
    ],
    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) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run 'trip search <name>' to find the exact Trip.com city name and use that for --from
  2. Correct spelling and try the official English city name
  3. Catch ArgumentError and present the suggested search command to the user
  4. Cache resolved city ids from prior successful searches to avoid repeat resolution failures

Example fix

// before
--from "Sao Palo"   // unresolved
// after
--from "Sao Paulo"  // resolved via 'trip search Sao Paulo'
Defensive patterns

Strategy: validation

Validate before calling

const origin = await resolvePackageCity(from);
if (!origin) {
  throw new Error(`Origin "${from}" not found — run 'trip search ${from}' first`);
}

Try / catch

try {
  await tripPackageSearch({ from, to });
} catch (e) {
  if (e instanceof ArgumentError && e.message.includes('Could not resolve origin')) {
    const matches = await tripCitySearch(from);
    throw new UserInputError(`Unknown origin. Did you mean: ${matches.map(m => m.name).join(', ')}?`);
  }
  throw e;
}

Prevention

When it happens

Trigger: --from contains a name not in Trip.com's city index: misspellings ('Sao Palo'), alternate/local names Trip.com doesn't index, empty or whitespace-only keywords that slip past parseKeyword, or very small towns without Trip.com coverage.

Common situations: Hard-coded city names from another provider's dataset, missing diacritics ('Zürich' vs 'Zurich' edge cases), renamed cities, or passing an airport/hotel name instead of a city.

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/9cdd134edfe18f40. Report an issue: GitHub.