jackwener/OpenCLI · error · ArgumentError
openreview ${label} is required
Error message
openreview ${label} is required What it means
requireForumId validates OpenReview forum/submission ids before any API call. It throws ArgumentError when the value is missing or whitespace-only, because an empty id would produce a meaningless API request. The label parameter names the argument in the message (e.g. 'id' or 'forum').
Source
Thrown at clis/openreview/utils.js:50
if (n > maxValue) {
throw new ArgumentError(`openreview ${label} must be <= ${maxValue}`);
}
return n;
}
export function requireNonNegativeInt(value, defaultValue, label = 'offset') {
const raw = value ?? defaultValue;
const n = coerceInt(raw);
if (!Number.isInteger(n) || n < 0) {
throw new ArgumentError(`openreview ${label} must be a non-negative integer`);
}
return n;
}
export function requireForumId(value, label = 'id') {
const id = String(value ?? '').trim();
if (!id) {
throw new ArgumentError(`openreview ${label} is required`);
}
if (!ID_PATTERN.test(id)) {
throw new ArgumentError(`openreview ${label} "${value}" is not a valid forum id (expected 6-20 chars of [A-Za-z0-9_-])`);
}
return id;
}
/** OpenReview profile ids are `~...N` slugs and may include dots, hyphens, and Unicode letters. */
const PROFILE_ID_PATTERN = /^~(?=.*\p{L})[\p{L}\p{M}0-9._-]+\d+$/u;
export function requireProfileId(value, label = 'profile') {
const id = String(value ?? '').trim();
if (!id) {
throw new ArgumentError(`openreview ${label} is required`);
}
if (!PROFILE_ID_PATTERN.test(id)) {
throw new ArgumentError(`openreview ${label} "${value}" is not a valid profile id (expected "~First_Last1" or similar; find it on the author's openreview.net profile URL)`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty forum id (e.g. the submission id from the OpenReview URL, like 'AbCdEf123456').
- Check CLI help for the required argument name and re-run with it supplied.
- In scripts, default/guard the variable: [ -n "$FORUM" ] || { echo 'FORUM required'; exit 1; }.
Example fix
// before
cli forum "$FORUM"
// after
cli forum "${FORUM:?set FORUM to an openreview forum id}" Defensive patterns
Strategy: validation
Validate before calling
function hasForumId(v) { return typeof v === 'string' && v.trim().length > 0; }
if (!hasForumId(args.id)) { console.error('usage: cli id <forum-id>'); process.exit(2); } Type guard
const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try { const id = requireForumId(args.id); } catch (e) { if (e instanceof ArgumentError) { console.error(e.message); process.exit(2); } throw e; } Prevention
- Always supply the id argument; extract it from the forum URL's ?id= parameter.
- Fail fast in scripts with ${VAR:?} parameter expansion.
- Trim user input but reject empty before calling the command.
When it happens
Trigger: Calling id(args) or forum(args) with args.id/args.forum undefined, null, empty string, or a string of only whitespace.
Common situations: User forgot the positional argument on the CLI; a script passes an empty variable after trimming; a JSON config has "forum": ""; shell variable unset so $FORUM expands to nothing.
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
- symbol is required
- <username> is required
- <game-url> is required
- Either --product-id or --url is required
- --city is required (numeric city ID from `ctrip search` or `
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/97260a62cfbb831e.
Report an issue: GitHub.