openai/codex · error · anyhow::Error

LookupAccountNameW failed for

Error message

LookupAccountNameW failed for {name}: {err}

What it means

LookupAccountNameW failed while resolving an account name (e.g. the sandbox group or user) to its SID, with a GetLastError other than ERROR_INSUFFICIENT_BUFFER (which the retry loop handles by resizing buffers). The account name could not be resolved to a SID at all — for example the account does not exist or the LSA lookup service failed — after the buffer-sizing iterations completed.

Solutions

  1. Check the GetLastError code in the message: ERROR_NONE_MAPPED (1332) means the account name does not exist on this machine
  2. If the name is a well-known account (Administrators, Users, Everyone, SYSTEM), let the code use its hardcoded SID string instead of a lookup
  3. Repair the Local Security Authority service or domain trust if lookups fail system-wide
  4. Recreate the missing sandbox user/group by re-running provisioning from scratch
Defensive patterns

Strategy: retry

When it happens

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

Appendix: source

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

                name_w.as_ptr(),
                sid_buffer.as_mut_ptr() as *mut c_void,
                &mut sid_len,
                domain.as_mut_ptr(),
                &mut domain_len,
                &mut use_type,
            )
        };
        if ok != 0 {
            sid_buffer.truncate(sid_len as usize);
            return Ok(sid_buffer);
        }
        let err = unsafe { GetLastError() };
        if err == ERROR_INSUFFICIENT_BUFFER {
            sid_buffer.resize(sid_len as usize, 0);
            domain.resize(domain_len as usize, 0);
            continue;
        }
        return Err(anyhow::anyhow!(
            "LookupAccountNameW failed for {name}: {err}"
        ));
    }
}

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));

View on GitHub (pinned to 339751715c)