{"record":{"id":"a6b07e086ffd53ca","repo":"openai/codex","slug":"approval-policy-never-cannot-be-used-because","errorCode":null,"errorMessage":"`approval_policy = \"never\"` cannot be used because requirements do not allow `sandbox_mode = \"danger-full-access\"`; Codex would fall back to read-only permissions with approvals disabled. Choose an `approval_policy` based on what you need, such as `on-request`, or choose an allowed sandbox mode.","messagePattern":"`approval_policy = \"never\"` cannot be used because requirements do not allow `sandbox_mode = \"danger-full-access\"`; Codex would fall back to read-only permissions with approvals disabled\\. Choose an `approval_policy` based on what you need, such as `on-request`, or choose an allowed sandbox mode\\.","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/core/src/config/mod.rs","lineNumber":3975,"sourceCode":"        apply_requirement_constrained_value(\n            \"approvals_reviewer\",\n            approvals_reviewer,\n            &mut constrained_approvals_reviewer,\n            &mut startup_warnings,\n        )?;\n        let permission_profile_was_constrained = apply_requirement_constrained_value(\n            \"permission_profile\",\n            permission_profile,\n            &mut constrained_permission_profile,\n            &mut startup_warnings,\n        )?;\n        if permission_profile_was_constrained\n            && sandbox_mode_requirement_for_permission_profile(&original_permission_profile)\n                == SandboxModeRequirement::DangerFullAccess\n            && constrained_permission_profile.get() == &PermissionProfile::read_only()\n            && constrained_approval_policy.value() == AskForApproval::Never\n        {\n            return Err(std::io::Error::new(\n                std::io::ErrorKind::InvalidInput,\n                \"`approval_policy = \\\"never\\\"` cannot be used because requirements do not allow `sandbox_mode = \\\"danger-full-access\\\"`; Codex would fall back to read-only permissions with approvals disabled. Choose an `approval_policy` based on what you need, such as `on-request`, or choose an allowed sandbox mode.\",\n            ));\n        }\n        if permission_profile_was_constrained {\n            // The selected profile no longer describes the effective\n            // permissions after requirements forced a fallback.\n            active_permission_profile = None;\n            profile_workspace_roots.clear();\n        }\n        apply_requirement_constrained_value(\n            \"web_search_mode\",\n            web_search_mode,\n            &mut constrained_web_search_mode,\n            &mut startup_warnings,\n        )?;\n\n        let mcp_servers = constrain_mcp_servers(cfg.mcp_servers.clone(), mcp_servers.as_ref())","sourceCodeStart":3957,"sourceCodeEnd":3993,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/core/src/config/mod.rs#L3957-L3993","documentation":"Managed requirements can constrain the permission profile. If the selected profile demands sandbox_mode = \"danger-full-access\", requirements forbid it, and the constrained profile falls back to read-only while the effective approval policy is Never, Codex would run read-only with approvals disabled: able neither to write nor to ask. Config::load refuses to start and directs you to a workable approval policy or an allowed sandbox mode.","triggerScenarios":"A requirements layer (e.g. enterprise-managed config) that disallows danger-full-access, combined with a permission profile requiring danger-full-access and an effective approval_policy of \"never\" (explicit or resolved via override). Fires only when the profile was actually constrained down to read-only.","commonSituations":"Corporate-managed Codex installs where users copy their personal full-trust config (never-approve plus full access); CI automation configs reused across environments with stricter requirements; bypass-style flags colliding with managed policy.","solutions":["Set `approval_policy = \"on-request\"` (or \"on-failure\") so escalation is still possible under the constrained profile.","Or select a permission profile whose sandbox mode the requirements allow (e.g. workspace-write), avoiding the read-only fallback.","Or have the requirements owner allow the needed sandbox mode for this workflow.","Also drop any override forcing Never (e.g. a bypass-approvals override) so the pairing cannot occur."],"exampleFix":"# before - never-approve paired with a full-access profile\napproval_policy = \"never\"\ndefault_permissions = \"full-access-profile-id\"\n\n# after - approvals available under an allowed profile\napproval_policy = \"on-request\"\ndefault_permissions = \"workspace-write-profile-id\"","handlingStrategy":"validation","validationCode":"# Pre-flight: never combine approval_policy=never with a profile\n# that requirements will constrain to read-only\nimport tomllib\ncfg = tomllib.load(open(\"config.toml\", \"rb\"))\nnever = cfg.get(\"approval_policy\") == \"never\"\nfull_access = cfg.get(\"default_permissions\") in FULL_ACCESS_PROFILE_IDS  # ids requiring danger-full-access\nif never and full_access and requirements_deny_danger_full_access():\n    raise SystemExit(\"pick on-request or an allowed profile\")","typeGuard":null,"tryCatchPattern":"match config_result {\n    Err(ref e) if e.kind() == std::io::ErrorKind::InvalidInput\n        && e.to_string().contains(\"requirements do not allow\") => {\n        // fall back to approval_policy = on-request and retry config load\n    }\n    other => other,\n}","preventionTips":["Never pair approval_policy = never with a danger-full-access profile under managed requirements","Read the requirements layer's allowed sandbox modes before choosing a profile","Prefer on-request in managed environments","Validate the config in a scratch CODEX_HOME before rollout"],"tags":["codex","approval-policy","sandbox","permissions","requirements"],"backgroundTag":"policy-conflict-detected","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}