jackwener/OpenCLI · error · InvalidArgumentError

--only must be one of: all, logged-in, not-logged-in, unknow

Error message

--only must be one of: all, logged-in, not-logged-in, unknown, error

What it means

collectAuthStatus validates the --only option of the auth status command against a fixed whitelist: all, logged-in, not-logged-in, unknown, error. Any other value raises this commander InvalidArgumentError before any sites are checked.

Source

Thrown at src/commands/auth.ts:420

  let next = 0;
  const runners = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
    while (next < items.length) {
      const index = next++;
      results[index] = await worker(items[index]);
    }
  });
  await Promise.all(runners);
  return results;
}

export async function collectAuthStatus(options: AuthStatusOptions): Promise<AuthStatusRow[]> {
  const selectedSites = parseSiteFilter(options.sites);
  const mode: AuthStatusMode = options.full ? 'full' : 'quick';
  const concurrency = parsePositiveInt(options.concurrency, '--concurrency', mode === 'full' ? 3 : 8);
  const timeoutSeconds = parsePositiveInt(options.timeout, '--timeout', mode === 'full' ? 20 : 8);
  const only = String(options.only ?? 'all');
  if (!['all', 'logged-in', 'not-logged-in', 'unknown', 'error'].includes(only)) {
    throw new InvalidArgumentError('--only must be one of: all, logged-in, not-logged-in, unknown, error');
  }

  const commands = authWhoamiCommands().filter(cmd => !selectedSites || selectedSites.has(cmd.site));
  const rows = await mapConcurrent(commands, concurrency, cmd => (
    mode === 'full'
      ? runFull(cmd, { timeoutSeconds, profile: options.profile })
      : runQuick(cmd, { timeoutSeconds, profile: options.profile })
  ));

  const normalizedOnly = only.replace(/-/g, '_');
  return normalizedOnly === 'all'
    ? rows
    : rows.filter(row => row.status === normalizedOnly);
}

export async function collectAuthRefresh(options: AuthRefreshOptions): Promise<AuthRefreshRow[]> {
  const selectedSites = parseSiteFilter(options.sites);
  const concurrency = parsePositiveInt(options.concurrency, '--concurrency', 3);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use one of the exact values: all, logged-in, not-logged-in, unknown, error.
  2. Run opencli auth status --help to see accepted values.
  3. Normalize/whitelist the value in scripts before forwarding it to --only.

Example fix

// before
opencli auth status --only loggedIn
// after
opencli auth status --only logged-in
Defensive patterns

Strategy: validation

Validate before calling

const ONLY_VALUES = ['all', 'logged-in', 'not-logged-in', 'unknown', 'error'] as const;
if (opts.only !== undefined && !ONLY_VALUES.includes(opts.only as any)) {
  throw new Error(`--only must be one of: ${ONLY_VALUES.join(', ')}`);
}

Type guard

type AuthOnly = 'all' | 'logged-in' | 'not-logged-in' | 'unknown' | 'error';
const isAuthOnly = (v: unknown): v is AuthOnly =>
  ['all', 'logged-in', 'not-logged-in', 'unknown', 'error'].includes(v as AuthOnly);

Try / catch

try {
  await opencli.authStatus({ only: opts.only });
} catch (e) {
  if (/--only must be one of/.test(e.message)) {
    console.error('Allowed values: all, logged-in, not-logged-in, unknown, error');
  } else throw e;
}

Prevention

When it happens

Trigger: opencli auth status --only loggedIn, --only "logged in", --only LOGIN, --only failed — i.e. any casing/spelling/synonym that is not exactly one of the five allowed strings.

Common situations: Guessing flag values without checking --help; using hyphenated variants like logged_in or notloggedin; shell scripts passing user input straight through to --only.

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


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