BigPizzaV3/CodexPlusPlus · error

主题市场包含无效 SHA-256

Error message

主题市场包含无效 SHA-256

What it means

Validation guard in validate_sha256: the expected hash string is not exactly 64 lowercase hex characters. Fires before hash comparison whenever a manifest entry or caller supplies a malformed digest, distinguishing 'badly formatted hash' from 'hash mismatch'.

Source

Thrown at crates/codex-plus-core/src/dream_skin_market.rs:380

    Ok(())
}

fn valid_theme_id(value: &str) -> bool {
    let bytes = value.as_bytes();
    (1..=64).contains(&bytes.len())
        && bytes[0].is_ascii_alphanumeric()
        && bytes.iter().all(|byte| {
            byte.is_ascii_lowercase() || byte.is_ascii_digit() || matches!(byte, b'-' | b'_')
        })
}

fn validate_sha256(value: &str) -> anyhow::Result<()> {
    if value.len() != 64
        || !value
            .bytes()
            .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte))
    {
        bail!("主题市场包含无效 SHA-256");
    }
    Ok(())
}

fn verify_sha256(bytes: &[u8], expected: &str, label: &str) -> anyhow::Result<()> {
    validate_sha256(expected)?;
    let actual = format!("{:x}", Sha256::digest(bytes));
    if actual != expected {
        bail!("{label} SHA-256 校验失败");
    }
    Ok(())
}

fn detect_image_extension(bytes: &[u8]) -> Option<&'static str> {
    if bytes.starts_with(b"\x89PNG\r\n\x1a\n") {
        Some("png")
    } else if bytes.starts_with(&[0xff, 0xd8, 0xff]) {
        Some("jpg")

View on GitHub (pinned to f2074595a2)

Solutions

  1. Regenerate the SHA-256 of the asset and store it as 64 lowercase hex chars
  2. Fix the manifest's hash field
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/dream_skin_market.rs:380 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/5664746214e3ae55. Report an issue: GitHub.