jackwener/OpenCLI · error · ArgumentError
huodongxing eventType must be 1 (offline) or 2 (online)
Error message
huodongxing eventType must be 1 (offline) or 2 (online)
What it means
buildEventsUrl restricts the optional eventType query parameter to '1' (offline events) or '2' (online events), matching the site's API. Any other cleaned string throws this ArgumentError before the request is built.
Source
Thrown at clis/huodongxing/events.js:163
if (!range) return true;
return range.start <= end && range.end >= start;
});
return filtered.map((row, index) => ({ ...row, rank: index + 1 }));
}
export function buildEventsUrl(args = {}) {
const dateRange = requireDateRangeArgs(args);
const params = new URLSearchParams();
params.set('orderby', 'o');
params.set('d', 'ts');
appendIfPresent(params, 'date', dateRange.date);
appendIfPresent(params, 'dateTo', dateRange.dateTo);
appendIfPresent(params, 'tag', args.tag);
appendIfPresent(params, 'city', args.city);
const eventType = cleanText(args.eventType);
if (eventType) {
if (eventType !== '1' && eventType !== '2') {
throw new ArgumentError('huodongxing eventType must be 1 (offline) or 2 (online)');
}
params.set('eventType', eventType);
}
appendIfPresent(params, 'qs', args.qs);
return `${BASE_URL}?${params.toString()}`;
}
export function extractEventRowsPayload(limit = 20) {
const maxLimit = 50;
const rawLimit = limit ?? 20;
const count = typeof rawLimit === 'number' ? rawLimit : Number(String(rawLimit).trim());
if (!Number.isInteger(count) || count <= 0 || count > maxLimit) {
return {
ok: false,
code: 'INVALID_LIMIT',
message: `huodongxing limit must be a positive integer <= ${maxLimit}`,
};
}View on GitHub (pinned to 49907e53dc)
Solutions
- Use exactly the string '1' for offline or '2' for online events
- Omit eventType entirely to query both kinds
- Convert a boolean/enum in your tool layer to '1'/'2' before calling
Example fix
// before
buildEventsUrl({ eventType: 'online' });
// after
buildEventsUrl({ eventType: '2' }); // or '1' for offline Defensive patterns
Strategy: validation
Validate before calling
const EVENT_TYPES = new Set(['1','2']);
if (args.eventType != null && !EVENT_TYPES.has(String(args.eventType))) {
throw new Error('eventType must be "1" (offline) or "2" (online)');
} Type guard
const isValidEventType = v => v == null || (typeof v === 'string' && ['1','2'].includes(v));
Try / catch
try { buildEventsUrl(args); } catch (e) { if (e instanceof ArgumentError && /eventType/.test(e.message)) { /* map 'online'->'2', 'offline'->'1' and retry */ } else throw e; } Prevention
- Treat eventType as the site's numeric enum, not free text
- Validate in your tool schema with enum: ['1','2']
- Omit the field instead of passing null/empty variants you invent
When it happens
Trigger: Passing args.eventType with any value other than the strings '1' or '2' to the events URL builder, e.g. 'online', '3', or ' true'.
Common situations: Using human-readable event type names instead of the site's numeric codes; passing a number instead of a string; guessing an enum value not documented by huodongxing.
Understand the failure class
Background: "invalid argument", "unknown mode", "not supported": invalid enum-like argument errors explained — this error's family across 19 libraries.
Related errors
- juejin category "${value}" is not recognised
- nowcoder search --type must be all or post
- weread-official: type must be one of: ${Object.keys(TYPE_ALI
- weread-official: scope must be one of: ${Object.keys(SEARCH_
- weread-official: ${label} must be one of: ${choices.join(',
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/aff3d7d4f8c19a77.
Report an issue: GitHub.