google-gemini/gemini-cli · error

Invalid approval mode: ${rawApprovalMode}. Valid values are:

Error message

Invalid approval mode: ${rawApprovalMode}. Valid values are: yolo, auto_edit, plan, default

What it means

Thrown from the `default` branch of the approval-mode switch when the resolved `rawApprovalMode` is not one of `yolo`, `auto_edit`, `plan`, or `default`. The value is resolved from `argv.approvalMode`, the `--yolo` flag, or `settings.general.defaultApprovalMode`. An unrecognized value means the user typed the flag wrong or wrote an invalid setting in `settings.json`.

Source

Thrown at packages/cli/src/config/config.ts:727

        break;
      case 'auto_edit':
        approvalMode = ApprovalMode.AUTO_EDIT;
        break;
      case 'plan':
        if (!(settings.general?.plan?.enabled ?? true)) {
          debugLogger.warn(
            'Approval mode "plan" is disabled in your settings. Falling back to "default".',
          );
          approvalMode = ApprovalMode.DEFAULT;
        } else {
          approvalMode = ApprovalMode.PLAN;
        }
        break;
      case 'default':
        approvalMode = ApprovalMode.DEFAULT;
        break;
      default:
        throw new Error(
          `Invalid approval mode: ${rawApprovalMode}. Valid values are: yolo, auto_edit, plan, default`,
        );
    }
  } else {
    approvalMode = ApprovalMode.DEFAULT;
  }

  // Override approval mode if disableYoloMode is set.
  if (settings.security?.disableYoloMode || settings.admin?.secureModeEnabled) {
    if (approvalMode === ApprovalMode.YOLO) {
      if (settings.admin?.secureModeEnabled) {
        debugLogger.error(
          'YOLO mode is disabled by "secureModeEnabled" setting.',
        );
      } else {
        debugLogger.error(
          'YOLO mode is disabled by the "disableYolo" setting.',
        );

View on GitHub (pinned to 5024443c72)

Solutions

  1. Use one of the four exact values: `yolo`, `auto_edit`, `plan`, `default`.
  2. Open `~/.gemini/settings.json` (or workspace `.gemini/settings.json`) and fix `general.defaultApprovalMode` to a valid string.
  3. If using `--yolo`, remove any conflicting `--approval-mode` flag.

Example fix

// before (settings.json)
{ "general": { "defaultApprovalMode": "auto" } }
// after
{ "general": { "defaultApprovalMode": "auto_edit" } }
Defensive patterns

Strategy: validation

Validate before calling

const VALID = new Set(['yolo', 'auto_edit', 'plan', 'default']);
function resolveApprovalMode(raw: string | undefined): string {
  if (raw === undefined) return 'default';
  if (!VALID.has(raw)) {
    throw new Error(`Invalid approval mode: ${raw}. Valid: ${[...VALID].join(', ')}`);
  }
  return raw;
}

Type guard

const APPROVAL_MODES = ['yolo', 'auto_edit', 'plan', 'default'] as const;
type ApprovalModeName = (typeof APPROVAL_MODES)[number];
function isApprovalMode(v: unknown): v is ApprovalModeName {
  return typeof v === 'string' && (APPROVAL_MODES as readonly string[]).includes(v);
}

Prevention

When it happens

Trigger: Setting `"defaultApprovalMode": "auto"` in settings.json (the correct value is `auto_edit`); running `gemini --approval-mode yolo2` or `--approval-mode yes`; misspelling the mode in a config file; an extension injecting an unknown mode.

Common situations: Typo in settings.json (e.g., `auto` instead of `auto_edit`); older docs or tutorials that reference a since-renamed mode; copy-pasting from a different tool's vocabulary (`yes`, `accept`, `always`).

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/464735e54bb642e6. Report an issue: GitHub.