{"record":{"id":"41e5c8393c5c2740","repo":"openai/codex","slug":"convertstringsidtosidw-failed-for-sid-str","errorCode":null,"errorMessage":"ConvertStringSidToSidW failed for {sid_str}: {}","messagePattern":"ConvertStringSidToSidW failed for (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs","lineNumber":270,"sourceCode":"    }\n}\n\nfn well_known_sid_str(name: &str) -> Option<&'static str> {\n    match name {\n        \"Administrators\" => Some(SID_ADMINISTRATORS),\n        \"Users\" => Some(SID_USERS),\n        \"Authenticated Users\" => Some(SID_AUTHENTICATED_USERS),\n        \"Everyone\" => Some(SID_EVERYONE),\n        \"SYSTEM\" => Some(SID_SYSTEM),\n        _ => None,\n    }\n}\n\nfn sid_bytes_from_string(sid_str: &str) -> Result<Vec<u8>> {\n    let sid_w = to_wide(OsStr::new(sid_str));\n    let mut psid: *mut c_void = std::ptr::null_mut();\n    if unsafe { ConvertStringSidToSidW(sid_w.as_ptr(), &mut psid) } == 0 {\n        return Err(anyhow::anyhow!(\n            \"ConvertStringSidToSidW failed for {sid_str}: {}\",\n            unsafe { GetLastError() }\n        ));\n    }\n    let sid_len = unsafe { GetLengthSid(psid) };\n    if sid_len == 0 {\n        unsafe {\n            LocalFree(psid as _);\n        }\n        return Err(anyhow::anyhow!(\"GetLengthSid failed for {sid_str}\"));\n    }\n    let mut out = vec![0u8; sid_len as usize];\n    let ok = unsafe { CopySid(sid_len, out.as_mut_ptr() as *mut c_void, psid) };\n    unsafe {\n        LocalFree(psid as _);\n    }\n    if ok == 0 {\n        return Err(anyhow::anyhow!(\"CopySid failed for {sid_str}\"));","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs#L252-L288","documentation":"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.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"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"}