affaan-m/ECC · error · Error

Unknown argument: ${arg}

Error message

Unknown argument: ${arg}

What it means

The argument parser in check-plugin-cache.js uses a lookup table (optionKeys) that maps only --codex-home, --plugin-dir, --marketplace, --plugin, and --version to their option keys. Any argument not in this table and not --help/-h triggers this error. The parser is intentionally strict — there are no positional arguments.

Source

Thrown at scripts/codex/check-plugin-cache.js:72

  const optionKeys = {
    '--codex-home': 'codexHome',
    '--plugin-dir': 'pluginDir',
    '--marketplace': 'marketplace',
    '--plugin': 'plugin',
    '--version': 'version',
  };
  let parsed = {};

  for (let index = 0; index < argv.length; index += 1) {
    const arg = argv[index];
    if (arg === '--help' || arg === '-h') {
      parsed = { ...parsed, help: true };
      continue;
    }

    const key = optionKeys[arg];
    if (!key) {
      throw new Error(`Unknown argument: ${arg}`);
    }

    const value = argv[index + 1];
    if (!value || value.startsWith('--')) {
      throw new Error(`Missing value for ${arg}`);
    }
    index += 1;

    parsed = { ...parsed, [key]: value };
  }

  const options = { ...defaults, ...parsed };
  return {
    ...options,
    marketplace: validateCacheSegment('--marketplace', options.marketplace),
    plugin: validateCacheSegment('--plugin', options.plugin),
    version: validateCacheSegment('--version', options.version),
    codexHome: path.resolve(options.codexHome),

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `node scripts/codex/check-plugin-cache.js --help` to see the accepted flags
  2. Check for typos in flag names
  3. Remove any flags not listed in the usage output

Example fix

// before
node scripts/codex/check-plugin-cache.js --verbose
// after
node scripts/codex/check-plugin-cache.js --help
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate arguments against the accepted flag set
const ACCEPTED = new Set(['--help', '-h', '--codex-home', '--plugin-dir', '--marketplace', '--plugin', '--version']);
const argv = process.argv.slice(2);
for (const arg of argv) {
  if (arg.startsWith('--') && !ACCEPTED.has(arg)) {
    console.error(`Unknown argument: ${arg}`);
    process.exit(1);
  }
}

Try / catch

try {
  const options = parseArgs(process.argv.slice(2));
} catch (error) {
  if (error.message.startsWith('Unknown argument:')) {
    console.error(error.message);
    usage();
    process.exit(2);
  }
  throw error;
}

Prevention

When it happens

Trigger: Passing an unsupported flag like --verbose, --debug, or --output; using a flag from a different tool; or a typo such as --plugn instead of --plugin.

Common situations: Running the script with flags from memory that don't exist; CI configurations referencing removed flags; shell aliases that inject unexpected arguments.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/d3c2a7f7699da5f7. Report an issue: GitHub.