{"record":{"id":"76ce01cafc8418fb","repo":"openai/codex","slug":"setfileattributesw-failed-for-err-error","errorCode":null,"errorMessage":"SetFileAttributesW failed for {}: {err} ({error})","messagePattern":"SetFileAttributesW failed for (.+?): (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/hide_users.rs","lineNumber":151,"sourceCode":"fn hide_directory(path: &Path) -> anyhow::Result<bool> {\n    let wide = to_wide(path);\n    let attrs = unsafe { GetFileAttributesW(wide.as_ptr()) };\n    if attrs == INVALID_FILE_ATTRIBUTES {\n        let err = unsafe { GetLastError() } as i32;\n        return Err(anyhow!(\n            \"GetFileAttributesW failed for {}: {err} ({error})\",\n            path.display(),\n            error = format_last_error(err)\n        ));\n    }\n    let new_attrs = attrs | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;\n    if new_attrs == attrs {\n        return Ok(false);\n    }\n    let ok = unsafe { SetFileAttributesW(wide.as_ptr(), new_attrs) };\n    if ok == 0 {\n        let err = unsafe { GetLastError() } as i32;\n        return Err(anyhow!(\n            \"SetFileAttributesW failed for {}: {err} ({error})\",\n            path.display(),\n            error = format_last_error(err)\n        ));\n    }\n    Ok(true)\n}\n","sourceCodeStart":133,"sourceCodeEnd":159,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/hide_users.rs#L133-L159","documentation":"SetFileAttributesW returned zero while trying to add FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM to a sandbox directory, so the directory could not be hidden from normal Explorer views. Usually a permissions or handle issue on the path.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/hide_users.rs:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the formatted Win32 error; ensure the process has write access to the path","Close any handles held against the directory and retry","Treat failure as non-fatal if hiding is cosmetic for the workflow"],"exampleFix":null,"handlingStrategy":"retry","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"}