openai/codex · error · anyhow::Error

LookupAccountSidW preflight failed for

Error message

LookupAccountSidW preflight failed for {sid_str}: {err}

What it means

The preflight LookupAccountSidW call (invoked with null buffers purely to learn the required name/domain sizes) failed with a GetLastError other than ERROR_INSUFFICIENT_BUFFER. This means the SID itself could not be mapped to an account at all — e.g. ERROR_NONE_MAPPED for an unknown SID — rather than the expected buffer-too-small result the sizing relies on; the SID is freed before failing.

Solutions

  1. Check the GetLastError code: ERROR_NONE_MAPPED (1332) means the SID does not correspond to any account on this machine
  2. Ensure the account behind the SID exists (re-run provisioning if the sandbox user/group was deleted)
  3. Repair LSA lookup functionality if no SIDs resolve on the system
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs:322 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/6045b260bbb498ee. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs:322

    let mut use_type: SID_NAME_USE = 0;
    let ok = unsafe {
        LookupAccountSidW(
            std::ptr::null(),
            psid,
            std::ptr::null_mut(),
            &mut name_len,
            std::ptr::null_mut(),
            &mut domain_len,
            &mut use_type,
        )
    };
    if ok == 0 {
        let err = unsafe { GetLastError() };
        if err != ERROR_INSUFFICIENT_BUFFER {
            unsafe {
                LocalFree(psid as _);
            }
            return Err(anyhow::anyhow!(
                "LookupAccountSidW preflight failed for {sid_str}: {err}"
            ));
        }
    }
    let mut name_buf: Vec<u16> = vec![0u16; name_len as usize];
    let mut domain_buf: Vec<u16> = vec![0u16; domain_len as usize];
    let ok = unsafe {
        LookupAccountSidW(
            std::ptr::null(),
            psid,
            name_buf.as_mut_ptr(),
            &mut name_len,
            domain_buf.as_mut_ptr(),
            &mut domain_len,
            &mut use_type,
        )
    };
    unsafe {

View on GitHub (pinned to 339751715c)