{"record":{"id":"046c6b0b910c32ec","repo":"openai/codex-plugin-cc","slug":"unsupported-review-scope-requestedscope-use","errorCode":null,"errorMessage":"Unsupported review scope \"${requestedScope}\". Use one of: auto, working-tree, branch, or pass --base <ref>.","messagePattern":"Unsupported review scope \"(.+?)\"\\. Use one of: auto, working-tree, branch, or pass --base <ref>\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/codex/scripts/lib/git.mjs","lineNumber":161,"sourceCode":"  if (baseRef) {\n    return {\n      mode: \"branch\",\n      label: `branch diff against ${baseRef}`,\n      baseRef,\n      explicit: true\n    };\n  }\n\n  if (requestedScope === \"working-tree\") {\n    return {\n      mode: \"working-tree\",\n      label: \"working tree diff\",\n      explicit: true\n    };\n  }\n\n  if (!supportedScopes.has(requestedScope)) {\n    throw new Error(\n      `Unsupported review scope \"${requestedScope}\". Use one of: auto, working-tree, branch, or pass --base <ref>.`\n    );\n  }\n\n  if (requestedScope === \"branch\") {\n    const detectedBase = detectDefaultBranch(cwd);\n    return {\n      mode: \"branch\",\n      label: `branch diff against ${detectedBase}`,\n      baseRef: detectedBase,\n      explicit: true\n    };\n  }\n\n  if (state.isDirty) {\n    return {\n      mode: \"working-tree\",\n      label: \"working tree diff\",","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/openai/codex-plugin-cc/blob/db52e28f4d9ded852ab3942cea316258ae4ef346/plugins/codex/scripts/lib/git.mjs#L143-L179","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Correct the scope value to one of: auto, working-tree, branch.","If you wanted a branch diff against a non-default ref, drop the bad scope and pass --base <ref> instead.","Validate scope before calling: const VALID = new Set(['auto','working-tree','branch']); if (!VALID.has(scope)) throw new Error(`bad scope: ${scope}`)."],"exampleFix":"// before\nresolveReviewTarget(cwd, { scope: \"worktree\" });\n\n// after\nresolveReviewTarget(cwd, { scope: \"working-tree\" });","handlingStrategy":"validation","validationCode":"const REVIEW_SCOPES = new Set([\"auto\", \"working-tree\", \"branch\"]);\n\nfunction safeResolveReviewTarget(cwd, options = {}) {\n  const scope = options.scope ?? \"auto\";\n  if (!options.base && !REVIEW_SCOPES.has(scope)) {\n    throw new Error(`Invalid scope '${scope}'. Use one of: ${[...REVIEW_SCOPES].join(\", \")}, or pass --base <ref>.`);\n  }\n  return resolveReviewTarget(cwd, options);\n}","typeGuard":"function isReviewScope(value) {\n  return value == null || [\"auto\", \"working-tree\", \"branch\"].includes(value);\n}","tryCatchPattern":"try {\n  resolveReviewTarget(cwd, { scope });\n} catch (err) {\n  if (/Unsupported review scope/.test(err.message)) {\n    console.error(err.message); // show the valid set, then default\n    resolveReviewTarget(cwd, { scope: \"auto\" });\n  } else throw err;\n}","preventionTips":["Treat scope as an enum: validate against the constant set before calling.","Source scope from a single constants module to avoid typos at call sites.","When accepting user input, normalize to lowercase and strip whitespace before validation."],"tags":["validation","codex-review","config","enum"],"backgroundTag":null,"analyzedSha":"db52e28f4d9ded852ab3942cea316258ae4ef346","analyzedAt":"2026-08-13T05:13:20.855Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}