openai/codex · error · anyhow::Error

must be a 64-character hex SHA-256 digest

Error message

{flag_name} must be a 64-character hex SHA-256 digest

What it means

Validation error in sha256_digest_arg: the value passed to --ws-token-sha256, after trimming, is not exactly 64 hexadecimal characters (the size of a SHA-256 digest). The flag expects the hex encoding of the 32-byte digest of the capability token.

Solutions

  1. Regenerate the digest with e.g. `sha256sum token.txt | cut -d' ' -f1` and pass the 64-char lowercase hex string.
  2. Check for accidental quotes, whitespace, or a base64 digest being passed instead of hex.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/app-server-transport/src/transport/auth.rs:428 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/cec77e0c29ff56ec. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/app-server-transport/src/transport/auth.rs:428

    })?;
    let trimmed = raw.trim();
    if trimmed.is_empty() {
        return Err(io::Error::new(
            ErrorKind::InvalidInput,
            format!("websocket auth secret {} must not be empty", path.display()),
        ));
    }
    Ok(trimmed.to_string())
}

fn absolute_path_arg(flag_name: &str, path: PathBuf) -> anyhow::Result<AbsolutePathBuf> {
    AbsolutePathBuf::try_from(path).with_context(|| format!("{flag_name} must be an absolute path"))
}

fn sha256_digest_arg(flag_name: &str, value: &str) -> anyhow::Result<[u8; 32]> {
    let trimmed = value.trim();
    if trimmed.len() != 64 {
        anyhow::bail!("{flag_name} must be a 64-character hex SHA-256 digest");
    }

    let mut digest = [0u8; 32];
    for (index, pair) in trimmed.as_bytes().chunks_exact(2).enumerate() {
        let high = hex_nibble(flag_name, pair[0])?;
        let low = hex_nibble(flag_name, pair[1])?;
        digest[index] = (high << 4) | low;
    }
    Ok(digest)
}

fn hex_nibble(flag_name: &str, byte: u8) -> anyhow::Result<u8> {
    match byte {
        b'0'..=b'9' => Ok(byte - b'0'),
        b'a'..=b'f' => Ok(byte - b'a' + 10),
        b'A'..=b'F' => Ok(byte - b'A' + 10),
        _ => anyhow::bail!("{flag_name} must be a 64-character hex SHA-256 digest"),
    }

View on GitHub (pinned to 339751715c)