jackwener/OpenCLI · error · ArgumentError
--${name} is required (numeric Trip.com hotel id, discover v
Error message
--${name} is required (numeric Trip.com hotel id, discover via the hotels list) What it means
parseHotelId requires a numeric Trip.com hotel id and throws this when the argument is missing, null, or whitespace-only. Hotel ids should be discovered via the hotels list command, as the message indicates.
Source
Thrown at clis/trip/utils.js:319
const detect = () => {
if (/captcha|verify you are human|security check/i.test(document.body?.innerText || '')) return 'captcha';
if (document.querySelector('.hotel-card')) return 'content';
return null;
};
const found = detect();
if (found) return resolve(found);
const observer = new MutationObserver(() => {
const result = detect();
if (result) { observer.disconnect(); resolve(result); }
});
observer.observe(document.documentElement, { childList: true, subtree: true });
setTimeout(() => { observer.disconnect(); resolve('timeout'); }, 12000);
})
`;
export function parseHotelId(name, raw) {
if (raw === undefined || raw === null || String(raw).trim() === '') {
throw new ArgumentError(`--${name} is required (numeric Trip.com hotel id, discover via the hotels list)`);
}
const value = String(raw).trim();
if (!/^\d+$/.test(value)) {
throw new ArgumentError(`--${name} must be a numeric Trip.com hotel id, got ${JSON.stringify(raw)}`);
}
return value;
}
export function buildHotelDetailUrl(hotelId) {
const params = new URLSearchParams({ hotelId, locale: 'en_US', curr: 'USD' });
return `https://www.trip.com/hotels/detail/?${params.toString()}`;
}
/**
* Browser-context IIFE that projects the single-hotel profile from
* `__NEXT_DATA__.props.pageProps.hotelDetailResponse` (the same SSR shape the
* mainland `ctrip hotel` detail uses). Rating sub-scores, popular amenities, and
* the check-in/out policy are each joined into one string so the profile stays aView on GitHub (pinned to 49907e53dc)
Solutions
- Supply the numeric hotel id, e.g. --hotel-id 12345678
- Run the hotels list command first (with a valid --city-id and dates) to discover hotel ids
- Ensure the variable holding the id from the list step is actually set before invoking
- Do not pass a hotel name — the id must be numeric
Example fix
// before clis-trip hotel-detail --hotel-id // after clis-trip hotels --city-id 338 --checkin 2026-10-01 --checkout 2026-10-05 clis-trip hotel-detail --hotel-id 12345678
Defensive patterns
Strategy: validation
Validate before calling
if (hotelId === undefined || hotelId === null || String(hotelId).trim() === '') {
throw new Error('--hotel-id is required (numeric Trip.com hotel id, discover via the hotels list)');
} Type guard
function isProvided(v) {
return v !== undefined && v !== null && String(v).trim() !== '';
} Try / catch
try {
runTripCli(['hotel-detail', '--hotel-id', hotelId]);
} catch (err) {
if (err instanceof ArgumentError && /--hotel-id is required/.test(err.message)) {
console.error('Run the hotels list first to get a numeric hotel id, then pass --hotel-id <digits>.');
process.exitCode = 2;
} else throw err;
} Prevention
- Chain the hotels-list command to capture an id before hotel-detail calls
- Assert the id variable is non-empty in wrapper scripts
- Store discovered ids in a cache keyed by city and dates
- Never pass hotel names where a numeric id is expected
When it happens
Trigger: Calling hotelId (which delegates to parseHotelId) without the flag, with --hotel-id '', or with an unset variable that yields an empty string.
Common situations: User skips the discovery step and runs a hotel-detail command directly; script reads an empty config key; the previous hotels-list call failed silently so no id was captured to pass along.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- --${name} is required (numeric Trip.com city id, e.g. 338 fo
- keyword must not be empty
- <from> station must not be empty
- <to> station must not be empty
- who 不能为空
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a4edaf3ff9d86e9c.
Report an issue: GitHub.