mirror of
https://github.com/openai/codex.git
synced 2026-11-25 07:23:22 +00:00
Fix read-only apply_patch rejection message (#16885)
Addresses #15532 Problem: Nested read-only `apply_patch` rejections report in-project files as outside the project. Solution: Choose the rejection message based on sandbox mode so read-only sessions report a read-only-specific reason, and add focused safety coverage.
This commit is contained in:
1 parent
3b32de4fab
commit
82506527f1
2 files changed
+46
-7
No files matched your search
@@ -12,6 +12,11 @@ use codex_protocol::protocol::SandboxPolicy;
|
||||
use codex_sandboxing::SandboxType;
|
||||
use codex_sandboxing::get_platform_sandbox;
|
||||
|
||||
const PATCH_REJECTED_OUTSIDE_PROJECT_REASON: &str =
|
||||
"writing outside of the project; rejected by user approval settings";
|
||||
const PATCH_REJECTED_READ_ONLY_REASON: &str =
|
||||
"writing is blocked by read-only sandbox; rejected by user approval settings";
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum SafetyCheck {
|
||||
AutoApprove {
|
||||
@@ -85,9 +90,7 @@ pub fn assess_patch_safety(
|
||||
None => {
|
||||
if rejects_sandbox_approval {
|
||||
SafetyCheck::Reject {
|
||||
reason:
|
||||
"writing outside of the project; rejected by user approval settings"
|
||||
.to_string(),
|
||||
reason: patch_rejection_reason(sandbox_policy).to_string(),
|
||||
}
|
||||
} else {
|
||||
SafetyCheck::AskUser
|
||||
@@ -97,14 +100,22 @@ pub fn assess_patch_safety(
|
||||
}
|
||||
} else if rejects_sandbox_approval {
|
||||
SafetyCheck::Reject {
|
||||
reason: "writing outside of the project; rejected by user approval settings"
|
||||
.to_string(),
|
||||
reason: patch_rejection_reason(sandbox_policy).to_string(),
|
||||
}
|
||||
} else {
|
||||
SafetyCheck::AskUser
|
||||
}
|
||||
}
|
||||
|
||||
fn patch_rejection_reason(sandbox_policy: &SandboxPolicy) -> &'static str {
|
||||
match sandbox_policy {
|
||||
SandboxPolicy::ReadOnly { .. } => PATCH_REJECTED_READ_ONLY_REASON,
|
||||
SandboxPolicy::WorkspaceWrite { .. }
|
||||
| SandboxPolicy::DangerFullAccess
|
||||
| SandboxPolicy::ExternalSandbox { .. } => PATCH_REJECTED_OUTSIDE_PROJECT_REASON,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_write_patch_constrained_to_writable_paths(
|
||||
action: &ApplyPatchAction,
|
||||
file_system_sandbox_policy: &FileSystemSandboxPolicy,
|
||||
|
||||
Reference in new issue
Block a user