openai/codex-plugin-cc · error · Error

Unexpected extra argument: ${arg}

Error message

Unexpected extra argument: ${arg}

What it means

Thrown by parseArgs() in bump-version.mjs when a second positional (non-dash) argument is encountered after a version was already assigned. The command accepts at most one positional argument (the version); any extra positional is rejected.

Source

Thrown at scripts/bump-version.mjs:112

  for (let i = 0; i < argv.length; i += 1) {
    const arg = argv[i];

    if (arg === "--check") {
      options.check = true;
    } else if (arg === "--root") {
      const root = argv[i + 1];
      if (!root) {
        throw new Error("--root requires a directory.");
      }
      options.root = root;
      i += 1;
    } else if (arg === "--help" || arg === "-h") {
      options.help = true;
    } else if (arg.startsWith("-")) {
      throw new Error(`Unknown option: ${arg}`);
    } else if (options.version) {
      throw new Error(`Unexpected extra argument: ${arg}`);
    } else {
      options.version = arg;
    }
  }

  options.root = path.resolve(options.root);
  return options;
}

function validateVersion(version) {
  if (!VERSION_PATTERN.test(version)) {
    throw new Error(`Expected a semver-like version such as 1.0.3, got: ${version}`);
  }
}

function requireObject(value, label) {
  if (!value || typeof value !== "object" || Array.isArray(value)) {
    throw new Error(`Expected ${label} to be an object.`);

View on GitHub (pinned to db52e28f4d)

Solutions

  1. Provide exactly one version positional: `node scripts/bump-version.mjs 1.0.0`.
  2. Quote any argument that contains spaces so it stays a single token.
  3. Remove the extra token; use flags (not positionals) for modifiers.

Example fix

// before
$ node scripts/bump-version.mjs 1.0.0 2.0.0

// after
$ node scripts/bump-version.mjs 1.0.0
Defensive patterns

Strategy: validation

Validate before calling

function countPositionals(argv) {
  return argv.filter((a) => !a.startsWith("-") && !(argv[argv.indexOf(a) - 1] === "--root")).length;
}
if (countPositionals(argv) > 1) {
  throw new Error("Only one positional argument (the version) is accepted.");
}

Prevention

When it happens

Trigger: Running `node scripts/bump-version.mjs 1.0.0 2.0.0` or `... 1.0.0 extra`. Once options.version is set, the next non-flag token triggers the error.

Common situations: Pasting two version numbers; an unquoted argument that shell-split into two tokens; intending --check but typing a bare word; a stray path or note appended to the command.

Related errors


AI-assisted analysis of openai/codex-plugin-cc@db52e28f4d (2026-08-13). Data as JSON: /api/errors/8ab35bebca6bcd4a. Report an issue: GitHub.