openai/codex · error · anyhow::Error
SetFileAttributesW failed for
Error message
SetFileAttributesW failed for {}: {err} ({error}) What it means
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.
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
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at codex-rs/windows-sandbox-rs/src/hide_users.rs:151 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/76ce01cafc8418fb.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/windows-sandbox-rs/src/hide_users.rs:151
fn hide_directory(path: &Path) -> anyhow::Result<bool> {
let wide = to_wide(path);
let attrs = unsafe { GetFileAttributesW(wide.as_ptr()) };
if attrs == INVALID_FILE_ATTRIBUTES {
let err = unsafe { GetLastError() } as i32;
return Err(anyhow!(
"GetFileAttributesW failed for {}: {err} ({error})",
path.display(),
error = format_last_error(err)
));
}
let new_attrs = attrs | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
if new_attrs == attrs {
return Ok(false);
}
let ok = unsafe { SetFileAttributesW(wide.as_ptr(), new_attrs) };
if ok == 0 {
let err = unsafe { GetLastError() } as i32;
return Err(anyhow!(
"SetFileAttributesW failed for {}: {err} ({error})",
path.display(),
error = format_last_error(err)
));
}
Ok(true)
}
View on GitHub (pinned to 339751715c)