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
- Use one of the four exact values: `yolo`, `auto_edit`, `plan`, `default`.
- Open `~/.gemini/settings.json` (or workspace `.gemini/settings.json`) and fix `general.defaultApprovalMode` to a valid string.
- 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
- Lint settings.json with a JSON schema to catch typos before launch.
- Note `auto_edit` uses an underscore, not a dash or space.
- Prefer setting the mode via `--approval-mode` so the shell surfaces typos immediately.
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
- Invalid telemetry configuration: ${err.message}.
- Invalid environment variable name: "${key}". Must contain on
- Invalid environment variable value for "${key}". Values cann
- Invalid scope: ${argv.scope}. Please use one of ${Object.val
- Invalid scope: ${argv.scope}. Please use one of ${Object.val
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/464735e54bb642e6.
Report an issue: GitHub.