openai/codex · error · anyhow::Error
ConvertStringSidToSidW failed for
Error message
ConvertStringSidToSidW failed for {sid_str}: {} What it means
ConvertStringSidToSidW returned 0 while converting an SSDL SID string (S-1-...) into a binary SID for account operations. The SID string passed in is malformed or cannot be parsed by the system, so it cannot be used to build ACLs or look up the account.
Solutions
- Verify the SID string in the message is a well-formed S-1-... identifier
- Check the GetLastError code for the precise parse failure
- If the SID came from a hardcoded well-known mapping, ensure the constant was not corrupted; otherwise re-resolve the account name to obtain a fresh SID string
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs:270 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/41e5c8393c5c2740.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs:270
}
}
fn well_known_sid_str(name: &str) -> Option<&'static str> {
match name {
"Administrators" => Some(SID_ADMINISTRATORS),
"Users" => Some(SID_USERS),
"Authenticated Users" => Some(SID_AUTHENTICATED_USERS),
"Everyone" => Some(SID_EVERYONE),
"SYSTEM" => Some(SID_SYSTEM),
_ => None,
}
}
fn sid_bytes_from_string(sid_str: &str) -> Result<Vec<u8>> {
let sid_w = to_wide(OsStr::new(sid_str));
let mut psid: *mut c_void = std::ptr::null_mut();
if unsafe { ConvertStringSidToSidW(sid_w.as_ptr(), &mut psid) } == 0 {
return Err(anyhow::anyhow!(
"ConvertStringSidToSidW failed for {sid_str}: {}",
unsafe { GetLastError() }
));
}
let sid_len = unsafe { GetLengthSid(psid) };
if sid_len == 0 {
unsafe {
LocalFree(psid as _);
}
return Err(anyhow::anyhow!("GetLengthSid failed for {sid_str}"));
}
let mut out = vec![0u8; sid_len as usize];
let ok = unsafe { CopySid(sid_len, out.as_mut_ptr() as *mut c_void, psid) };
unsafe {
LocalFree(psid as _);
}
if ok == 0 {
return Err(anyhow::anyhow!("CopySid failed for {sid_str}"));View on GitHub (pinned to 339751715c)