jackwener/OpenCLI · error · ArgumentError
destination is required
Error message
destination is required
What it means
The search command's func reads kwargs.destination, trims it, and throws ArgumentError when the result is empty. A destination is mandatory for every search, so the command fails fast before any date normalization or page navigation. This guards against null/undefined/empty-string/whitespace-only destination values.
Source
Thrown at clis/booking/search.js:241
{ name: 'offset', type: 'int', default: 0, help: 'Result offset for pagination (multiple of 25)' },
],
columns: [
'rank',
'name',
'country',
'slug',
'star_rating',
'review_score',
'review_count',
'price_amount',
'price_currency',
'distance',
'recommended_room',
'url',
],
func: async (page, kwargs) => {
const destination = String(kwargs.destination || '').trim();
if (!destination) throw new ArgumentError('destination is required');
const checkin = normalizeDate(kwargs.checkin, 'checkin');
const checkout = normalizeDate(kwargs.checkout, 'checkout');
if (checkin >= checkout) {
throw new ArgumentError(`checkout (${checkout}) must be after checkin (${checkin})`);
}
const adults = normalizePositiveInt(kwargs.adults, 2, 'adults', 30);
const rooms = normalizePositiveInt(kwargs.rooms, 1, 'rooms', 30);
const children = normalizeNonNegativeInt(kwargs.children, 0, 'children', 10);
const currency = normalizeCurrency(kwargs.currency);
const lang = normalizeLang(kwargs.lang);
const limit = normalizePositiveInt(kwargs.limit, 25, 'limit', 100);
const offset = normalizeNonNegativeInt(kwargs.offset, 0, 'offset', 1000);
const url = buildSearchUrl({ destination, checkin, checkout, adults, rooms, children, offset, currency, lang });
try {
await page.goto(url);
} catch (err) {View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty destination string, e.g. 'Tokyo' or 'Paris, France'
- Check that the key is exactly 'destination' (no typo, correct casing) in your kwargs/config
- Trim and validate the value before calling; reject blank/whitespace-only input early in your own code
- If searches without a destination are legitimate for your use case, this CLI cannot do them — supply at least a city/region
Example fix
// before
await search(page, { checkin: '2026-09-01', checkout: '2026-09-05' });
// after
await search(page, { destination: 'Tokyo', checkin: '2026-09-01', checkout: '2026-09-05' }); Defensive patterns
Strategy: validation
Validate before calling
function assertDestination(kwargs) {
const d = String(kwargs.destination ?? '').trim();
if (!d) throw new Error('destination is required before calling search');
return d;
} Type guard
function hasDestination(kwargs) {
return typeof kwargs.destination === 'string' && kwargs.destination.trim().length > 0;
} Try / catch
try {
await search(page, kwargs);
} catch (e) {
if (e.message === 'destination is required') {
throw new Error('Provide a destination (city/region) to search');
} else throw e;
} Prevention
- Validate required kwargs at the entry point of your wrapper code
- Check key spelling and casing ('destination', not 'Destination' or 'location')
- Do not allow blank/whitespace-only destination input in forms that feed this CLI
- Default-fill a destination from context if your workflow can search 'near me' equivalents
When it happens
Trigger: Calling the search tool with destination omitted, null, undefined, '' or ' '; programmatic callers spreading kwargs from an object where destination was never set; form submissions that allow blank destination.
Common situations: Forgotten required field in a wrapper script; a UI allowing 'search anywhere' which this CLI does not support; env/config keys spelled differently (DESTINATION vs destination) yielding undefined; JSON kwargs with a null destination.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
- archive search limit must be <= 100
- archive search query must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e21903c14a68eb6c.
Report an issue: GitHub.