jackwener/OpenCLI · warning · ArgumentError
--type must be private or group, got ${JSON.stringify(raw)}
Error message
--type must be private or group, got ${JSON.stringify(raw)} What it means
This ArgumentError is thrown by parseTourType when --type is supplied but is not exactly 'private' or 'group' (case-insensitive, trimmed). The value maps to Trip.com tab names (privateTours/groupTours), so an unknown value would produce an invalid search URL and the library fails fast at argument validation instead.
Source
Thrown at clis/trip/tour.js:21
*
* Trip.com's tour results (`package-tours/list?kwd=<keyword>`) load through a
* signed POST that only fires on a search submit, so this navigates the results
* page and lets the page issue its own signed request while a fetch hook captures
* the `products` response, rather than replaying the signature (see
* `buildTourSearchJs` in utils). Per-departure pricing and availability sit behind
* the booking step; the row `price` is the starting per-person estimate shown.
*/
import { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { buildTourSearchJs, buildTourSearchUrl, parseKeyword, parseListLimit } from './utils.js';
const TOUR_TABS = { private: 'privateTours', group: 'groupTours' };
function parseTourType(raw) {
if (raw === undefined || raw === null || raw === '') return TOUR_TABS.private;
const value = String(raw).trim().toLowerCase();
if (!TOUR_TABS[value]) {
throw new ArgumentError(`--type must be private or group, got ${JSON.stringify(raw)}`);
}
return TOUR_TABS[value];
}
cli({
site: 'trip',
name: 'tour',
access: 'read',
description: 'Search Trip.com tour packages by destination keyword (private or group tours)',
domain: 'trip.com',
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [
{ name: 'query', required: true, positional: true, help: 'Destination or tour keyword (e.g. Tokyo / Kyoto / Bali)' },
{ name: 'type', default: 'private', help: 'Tour line: private or group (default private)' },
{ name: 'limit', type: 'int', default: 20, help: 'Number of tours (1-50)' },
],View on GitHub (pinned to 49907e53dc)
Solutions
- Use exactly --type=private or --type=group (case/whitespace are normalized automatically).
- Omit --type entirely — it defaults to private (privateTours).
- Wrap the value in quotes if it contains spaces, though any spaced value will still be rejected.
- Check the CLI help text for the accepted enum values.
Example fix
// before cli --type "Private Tours" --query "Tokyo" // after cli --type private --query "Tokyo" // or omit --type for the private default
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = ['private', 'group'];
const t = raw == null ? undefined : String(raw).trim().toLowerCase();
if (t !== undefined && !ALLOWED.includes(t)) throw new Error(`--type must be private or group, got ${JSON.stringify(raw)}`); Type guard
function isTourType(v) { return v === 'private' || v === 'group'; } Try / catch
try {
await tripTour({ query, type: rawType });
} catch (e) {
if (e instanceof ArgumentError) {
console.error('Invalid --type; use private or group (default: private)');
process.exitCode = 2;
return;
}
throw e;
} Prevention
- Only pass 'private' or 'group' — never free-form strings or localized labels.
- Omit --type to use the private default.
- Validate CLI enums in wrappers/scripts before invoking.
- Check --help for accepted values when unsure.
When it happens
Trigger: Passing --type with any value other than private/group — e.g. --type=Private Tours, --type=day-tour, --type=1, or a quoted multi-word value.
Common situations: Users guessing valid type names from other travel CLIs; copy-pasting '--type private tours'; shell quoting issues yielding embedded values; abbreviations like 'priv' or 'grp'.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
- --from and --to must differ; both resolved to ${fromStation.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/285c8443031dd4ac.
Report an issue: GitHub.