{"record":{"id":"22d8dea430c608d3","repo":"jackwener/OpenCLI","slug":"could-not-resolve-destination-to-to-a-trip-co","errorCode":null,"errorMessage":"Could not resolve destination \"${to}\" to a Trip.com city; run 'trip search ${to}' to find the name","messagePattern":"Could not resolve destination \"(.+?)\" 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":67,"sourceCode":"    ],\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) {\n            throw new EmptyResultError('trip package', `No flight+hotel packages for ${origin.name} to ${dest.name} on ${depart} .. ${ret}`);\n        }\n        const rows = groups\n            .filter((g) => g && Array.isArray(g.flightlist) && g.flightlist.length)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/package.js#L49-L85","documentation":"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.","triggerScenarios":"--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.","commonSituations":"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.","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"],"exampleFix":"// before\n--to \"NRT\" // airport code, unresolved\n// after\n--to \"Tokyo\" // resolved via 'trip search Tokyo'","handlingStrategy":"validation","validationCode":"const dest = await resolvePackageCity(to);\nif (!dest) {\n  throw new Error(`Destination \"${to}\" not found — run 'trip search ${to}' 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 destination')) {\n    const matches = await tripCitySearch(to);\n    throw new UserInputError(`Unknown destination. Did you mean: ${matches.map(m => m.name).join(', ')}?`);\n  }\n  throw e;\n}","preventionTips":["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"],"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"}