{"record":{"id":"372c1249d2b161c3","repo":"jackwener/OpenCLI","slug":"name-is-required-numeric-trip-com-city-id-e","errorCode":null,"errorMessage":"--${name} is required (numeric Trip.com city id, e.g. 338 for London)","messagePattern":"--(.+?) is required \\(numeric Trip\\.com city id, e\\.g\\. 338 for London\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/trip/utils.js","lineNumber":244,"sourceCode":"    const detect = () => {\n      if (/captcha|verify you are human|security check/i.test(document.body?.innerText || '')) return 'captcha';\n      if (document.querySelector('.result-item')) return 'content';\n      return null;\n    };\n    const found = detect();\n    if (found) return resolve(found);\n    const observer = new MutationObserver(() => {\n      const result = detect();\n      if (result) { observer.disconnect(); resolve(result); }\n    });\n    observer.observe(document.documentElement, { childList: true, subtree: true });\n    setTimeout(() => { observer.disconnect(); resolve('timeout'); }, 12000);\n  })\n`;\n\nexport function parseCityId(name, raw) {\n    if (raw === undefined || raw === null || String(raw).trim() === '') {\n        throw new ArgumentError(`--${name} is required (numeric Trip.com city id, e.g. 338 for London)`);\n    }\n    const value = String(raw).trim();\n    if (!/^\\d+$/.test(value)) {\n        throw new ArgumentError(`--${name} must be a numeric Trip.com city id, got ${JSON.stringify(raw)}`);\n    }\n    return value;\n}\n\nexport function buildHotelSearchUrl(cityId, checkin, checkout) {\n    const params = new URLSearchParams({\n        city: cityId,\n        checkin,\n        checkout,\n        locale: 'en_US',\n        curr: 'USD',\n    });\n    return `https://www.trip.com/hotels/list?${params.toString()}`;\n}","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/utils.js#L226-L262","documentation":"parseCityId requires a numeric Trip.com city id (e.g. 338 for London) and throws this when the argument is missing, null, or whitespace-only. City ids are Trip.com-internal numeric identifiers, distinct from IATA codes.","triggerScenarios":"Calling cityId (which delegates to parseCityId) without the flag, with --city-id '', or with an unset variable interpolated as empty.","commonSituations":"User passes 'LON' (IATA code) in the wrong field but omits the actual city-id flag; script variables not exported; config file key missing so the value resolves to empty.","solutions":["Supply the numeric id, e.g. --city-id 338","Look up the city id via the Trip.com city/search listing if unknown (London is 338)","Do not pass an IATA code or city name here — the id is numeric","If the value comes from a variable/config, ensure it is set and non-empty"],"exampleFix":"// before\nclis-trip hotels --city-id LON --checkin 2026-10-01\n// after\nclis-trip hotels --city-id 338 --checkin 2026-10-01","handlingStrategy":"validation","validationCode":"if (cityId === undefined || cityId === null || String(cityId).trim() === '') {\n  throw new Error('--city-id is required (numeric Trip.com city id)');\n}","typeGuard":"function isProvided(v) {\n  return v !== undefined && v !== null && String(v).trim() !== '';\n}","tryCatchPattern":"try {\n  runTripCli(['hotels', '--city-id', cityId, '--checkin', ci, '--checkout', co]);\n} catch (err) {\n  if (err instanceof ArgumentError && /--city-id is required/.test(err.message)) {\n    console.error('Provide a numeric Trip.com city id (run the city search first, e.g. 338 for London).');\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Resolve city ids via the Trip.com city search before running dependent commands","Fail fast in wrappers when the id variable is empty","Don't reuse IATA codes in place of Trip.com numeric ids","Keep a local cache of city name -> id mappings"],"tags":["cli","missing-argument","trip-com"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}