Clarify Windows sandbox helper cancellation

This commit is contained in:
David Wiesen
2026-05-04 09:48:19 -07:00
parent 443f6b831e
commit 8a3f640950
@@ -596,6 +596,17 @@ fn report_helper_failure(
}
}
fn setup_helper_launch_failure_message(last_error: u32) -> String {
if last_error == ERROR_CANCELLED {
"Windows canceled the sandbox setup helper launch (Win32 error 1223). \
This usually means the Administrator/UAC prompt was dismissed, denied, or blocked by policy; \
try again and approve the elevation request."
.to_string()
} else {
format!("ShellExecuteExW failed to launch setup helper: {last_error}")
}
}
fn run_setup_exe(
payload: &ElevationPayload,
needs_elevation: bool,
@@ -682,7 +693,7 @@ fn run_setup_exe(
};
return Err(failure(
code,
format!("ShellExecuteExW failed to launch setup helper: {last_error}"),
setup_helper_launch_failure_message(last_error),
));
}
unsafe {
@@ -950,6 +961,7 @@ mod tests {
use super::offline_proxy_settings_from_env;
use super::profile_read_roots;
use super::proxy_ports_from_env;
use super::setup_helper_launch_failure_message;
use crate::helper_materialization::helper_bin_dir;
use crate::policy::SandboxPolicy;
use codex_utils_absolute_path::AbsolutePathBuf;
@@ -1454,4 +1466,13 @@ mod tests {
.all(|path| roots.contains(&path))
);
}
#[test]
fn canceled_helper_launch_message_is_actionable() {
let message = setup_helper_launch_failure_message(super::ERROR_CANCELLED);
assert!(message.contains("Win32 error 1223"));
assert!(message.contains("Administrator/UAC prompt"));
assert!(message.contains("approve the elevation request"));
}
}