{"record":{"id":"2d31d10f4da5a255","repo":"openai/codex","slug":"api-sandbox-dir-failed-res","errorCode":null,"errorMessage":"{api} sandbox dir failed: {res}","messagePattern":"(.+?) sandbox dir failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/bin/setup_main/win.rs","lineNumber":405,"sourceCode":"            ),\n            None => {\n                let path_w = to_wide(dir.as_os_str());\n                (\n                    SetNamedSecurityInfoW(\n                        path_w.as_ptr() as *mut u16,\n                        SE_FILE_OBJECT,\n                        DACL_SECURITY_INFORMATION,\n                        std::ptr::null_mut(),\n                        std::ptr::null_mut(),\n                        new_dacl,\n                        std::ptr::null_mut(),\n                    ),\n                    \"SetNamedSecurityInfoW\",\n                )\n            }\n        };\n        if res != 0 {\n            return Err(anyhow::anyhow!(\"{api} sandbox dir failed: {res}\"));\n        }\n        if !new_dacl.is_null() {\n            LocalFree(new_dacl as HLOCAL);\n        }\n        for sid in sids {\n            if !sid.is_null() {\n                LocalFree(sid as HLOCAL);\n            }\n        }\n    }\n    Ok(())\n}\n\npub fn main() -> Result<()> {\n    let ret = real_main();\n    if let Err(e) = &ret {\n        // Best-effort: log unexpected top-level errors.\n        if let Ok(codex_home) = std::env::var(\"CODEX_HOME\") {","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/bin/setup_main/win.rs#L387-L423","documentation":"Applying the newly built DACL to the sandbox directory failed: depending on which branch ran, either SetKernelObjectSecurity (on the held no-reparse handle) or SetNamedSecurityInfoW (on the path) returned a nonzero status. The message names the exact API that failed, so the sandbox directory remains without the intended restrictive ACL.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win.rs:405 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Decode the returned Win32 error to distinguish access-denied (needs elevation) from invalid-owner/privilege errors","Run the setup binary elevated so SE_SECURITY_PRIVILEGE and WRITE_DAC on the directory are available","If ownership is the issue, take ownership of the sandbox directory as administrator and re-run setup","Check the named branch only fires when no handle was available; prefer re-running so the handle-based branch is used"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}