{"record":{"id":"9cdd134edfe18f40","repo":"jackwener/OpenCLI","slug":"could-not-resolve-origin-from-to-a-trip-com-c","errorCode":null,"errorMessage":"Could not resolve origin \"${from}\" to a Trip.com city; run 'trip search ${from}' to find the name","messagePattern":"Could not resolve origin \"(.+?)\" to a Trip\\.com city; run 'trip search (.+?)' to find the name","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/trip/package.js","lineNumber":63,"sourceCode":"        'from', 'to',\n        'departure', 'arrival',\n        'stops',\n        'price', 'currency',\n    ],\n    func: async (kwargs) => {\n        const from = parseKeyword('from', kwargs.from);\n        const to = parseKeyword('to', kwargs.to);\n        const depart = parseIsoDate('depart', kwargs.depart);\n        const ret = parseIsoDate('return', kwargs.return);\n        if (depart >= ret) {\n            throw new ArgumentError(`--depart must be before --return (got ${depart} .. ${ret})`);\n        }\n        const adults = parseAdults(kwargs.adults);\n        const limit = parseListLimit(kwargs.limit);\n\n        const origin = await resolvePackageCity(from);\n        if (!origin) {\n            throw new ArgumentError(`Could not resolve origin \"${from}\" to a Trip.com city; run 'trip search ${from}' to find the name`);\n        }\n        const dest = await resolvePackageCity(to);\n        if (!dest) {\n            throw new ArgumentError(`Could not resolve destination \"${to}\" to a Trip.com city; run 'trip search ${to}' to find the name`);\n        }\n        if (origin.cityId === dest.cityId) {\n            throw new ArgumentError(`--from and --to must differ (both resolved to ${dest.name})`);\n        }\n\n        const groups = await fetchPackageSearch({\n            dcode: origin.cityCode,\n            acode: dest.cityCode,\n            hcityid: String(dest.cityId),\n            depart,\n            ret,\n            adults,\n        });\n        if (groups.length === 0) {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/package.js#L45-L81","documentation":"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.","triggerScenarios":"--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.","commonSituations":"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.","solutions":["Run 'trip search <name>' to find the exact Trip.com city name and use that for --from","Correct spelling and try the official English city name","Catch ArgumentError and present the suggested search command to the user","Cache resolved city ids from prior successful searches to avoid repeat resolution failures"],"exampleFix":"// before\n--from \"Sao Palo\"   // unresolved\n// after\n--from \"Sao Paulo\"  // resolved via 'trip search Sao Paulo'","handlingStrategy":"validation","validationCode":"const origin = await resolvePackageCity(from);\nif (!origin) {\n  throw new Error(`Origin \"${from}\" not found — run 'trip search ${from}' first`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await tripPackageSearch({ from, to });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('Could not resolve origin')) {\n    const matches = await tripCitySearch(from);\n    throw new UserInputError(`Unknown origin. Did you mean: ${matches.map(m => m.name).join(', ')}?`);\n  }\n  throw e;\n}","preventionTips":["Resolve city names with 'trip search' before package searches","Use exact official English city names from Trip.com results","Cache known-good city ids/names for reuse","Never pass airport codes or landmark names as --from"],"tags":["validation","cli","city-resolution","trip-com","arguments"],"backgroundTag":"invalid-cli-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}