jackwener/OpenCLI · error · CliError

ARGUMENT

ARGUMENT

Error message

A review token is required.

What it means

The paperreview `review` command requires a review token to fetch the review result. It trims kwargs.token and throws CliError with code ARGUMENT when empty, before any HTTP request is made. This fails fast so the user corrects the invocation rather than hitting the API.

Source

Thrown at clis/paperreview/review.js:20

import { CliError } from '@jackwener/opencli/errors';
import { PAPERREVIEW_DOMAIN, buildReviewUrl, ensureSuccess, requestJson, summarizeReview, } from './utils.js';
cli({
    site: 'paperreview',
    name: 'review',
    access: 'read',
    description: 'Fetch a paperreview.ai review by token',
    domain: PAPERREVIEW_DOMAIN,
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'token', positional: true, required: true, help: 'Review token returned by paperreview.ai' },
        { name: 'timeout', type: 'int', required: false, default: 30, help: 'Max seconds for the overall command (default: 30)' },
    ],
    columns: ['status', 'title', 'venue', 'numerical_score', 'has_feedback', 'review_url'],
    func: async (kwargs) => {
        const token = String(kwargs.token ?? '').trim();
        if (!token) {
            throw new CliError('ARGUMENT', 'A review token is required.');
        }
        const { response, payload } = await requestJson(`/api/review/${encodeURIComponent(token)}`);
        if (response.status === 202) {
            return {
                status: 'processing',
                token,
                review_url: buildReviewUrl(token),
                title: '',
                venue: '',
                numerical_score: '',
                has_feedback: '',
                message: typeof payload === 'object' && payload ? payload.detail ?? 'Review is still processing.' : 'Review is still processing.',
            };
        }
        ensureSuccess(response, payload, 'Failed to fetch the review.', 'Check the token and try again');
        return summarizeReview(token, payload);
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run with --token <your-review-token>.
  2. Echo/verify the token variable in scripts before invoking.
  3. Wait for the review request to complete and use the token it issued.

Example fix

// before
cli review
// after
cli review --token abc123
Defensive patterns

Strategy: validation

Validate before calling

const token = process.env.REVIEW_TOKEN;
if (!token || !token.trim()) {
  throw new Error('REVIEW_TOKEN is empty; run the submit step first');
}

Type guard

function hasToken(v) {
  return typeof v === 'string' && v.trim().length > 0;
}

Try / catch

try {
  await cli.review({ token: tokenArg });
} catch (err) {
  if (err.code === 'ARGUMENT') console.error('Pass --token <review-token>');
  else throw err;
}

Prevention

When it happens

Trigger: Running the review command without --token, or passing an empty/whitespace-only token value.

Common situations: Automating the command with an environment variable that was never set; dropping the flag when re-running a long command line; token email not yet received.

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/cd3baf2c1c68286e. Report an issue: GitHub.