openai/codex · error · anyhow::Error

CopySid failed for {sid_str}

Error message

CopySid failed for {sid_str}

What it means

Error "CopySid failed for {sid_str}" thrown in openai/codex.

Source

Thrown at codex-rs/windows-sandbox-rs/src/winutil.rs:203

        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 std::ffi::c_void, psid) };
    unsafe {
        LocalFree(psid as _);
    }
    if ok == 0 {
        return Err(anyhow::anyhow!("CopySid failed for {sid_str}"));
    }
    Ok(out)
}

#[cfg(test)]
mod tests {
    use super::argv_to_command_line;
    use pretty_assertions::assert_eq;

    #[test]
    fn argv_to_command_line_quotes_each_argument_independently() {
        let argv = vec![
            "cmd.exe".to_string(),
            "/c".to_string(),
            "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -NoProfile -EncodedCommand abc=="
                .to_string(),
        ];

View on GitHub (pinned to 339751715c)

Solutions

  1. Ensure the source SID is valid and the destination buffer is sized from GetLengthSid before copying.

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/winutil.rs:203 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/2f0ee42739d98bbb. Report an issue: GitHub.