openai/codex-plugin-cc · error · Error

Unsupported review scope "${requestedScope}". Use one of: au

Error message

Unsupported review scope "${requestedScope}". Use one of: auto, working-tree, branch, or pass --base <ref>.

What it means

Thrown by resolveReviewTarget() when options.scope is set to a value outside the supported set {auto, working-tree, branch} and no --base ref was provided. The scope is a strict enum; any typo or unsupported value is rejected before branch detection runs.

Source

Thrown at plugins/codex/scripts/lib/git.mjs:161

  if (baseRef) {
    return {
      mode: "branch",
      label: `branch diff against ${baseRef}`,
      baseRef,
      explicit: true
    };
  }

  if (requestedScope === "working-tree") {
    return {
      mode: "working-tree",
      label: "working tree diff",
      explicit: true
    };
  }

  if (!supportedScopes.has(requestedScope)) {
    throw new Error(
      `Unsupported review scope "${requestedScope}". Use one of: auto, working-tree, branch, or pass --base <ref>.`
    );
  }

  if (requestedScope === "branch") {
    const detectedBase = detectDefaultBranch(cwd);
    return {
      mode: "branch",
      label: `branch diff against ${detectedBase}`,
      baseRef: detectedBase,
      explicit: true
    };
  }

  if (state.isDirty) {
    return {
      mode: "working-tree",
      label: "working tree diff",

View on GitHub (pinned to db52e28f4d)

Solutions

  1. Correct the scope value to one of: auto, working-tree, branch.
  2. If you wanted a branch diff against a non-default ref, drop the bad scope and pass --base <ref> instead.
  3. Validate scope before calling: const VALID = new Set(['auto','working-tree','branch']); if (!VALID.has(scope)) throw new Error(`bad scope: ${scope}`).

Example fix

// before
resolveReviewTarget(cwd, { scope: "worktree" });

// after
resolveReviewTarget(cwd, { scope: "working-tree" });
Defensive patterns

Strategy: validation

Validate before calling

const REVIEW_SCOPES = new Set(["auto", "working-tree", "branch"]);

function safeResolveReviewTarget(cwd, options = {}) {
  const scope = options.scope ?? "auto";
  if (!options.base && !REVIEW_SCOPES.has(scope)) {
    throw new Error(`Invalid scope '${scope}'. Use one of: ${[...REVIEW_SCOPES].join(", ")}, or pass --base <ref>.`);
  }
  return resolveReviewTarget(cwd, options);
}

Type guard

function isReviewScope(value) {
  return value == null || ["auto", "working-tree", "branch"].includes(value);
}

Try / catch

try {
  resolveReviewTarget(cwd, { scope });
} catch (err) {
  if (/Unsupported review scope/.test(err.message)) {
    console.error(err.message); // show the valid set, then default
    resolveReviewTarget(cwd, { scope: "auto" });
  } else throw err;
}

Prevention

When it happens

Trigger: Calling resolveReviewTarget(cwd, {scope:'<anything-not-auto|working-tree|branch>'}) without also passing options.base. Examples: scope:'repository', scope:'commit', scope:'Main', or a scope sourced from a mistyped CLI flag.

Common situations: A typo in the --scope flag (e.g. `--scope worktree` instead of `--scope working-tree`); an outdated caller passing a scope name from an older/newer API version; case mismatch ('Working-Tree'); passing an empty-string scope explicitly.

Related errors


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