BigPizzaV3/CodexPlusPlus · error
主题市场包含无效 SHA-256
Error message
主题市场包含无效 SHA-256
What it means
validate_sha256 checks that a theme-market hash string is exactly 64 lowercase hex characters (0-9, a-f). The library throws this when any SHA-256 value entering the theme market validation path (validate_market_theme or verify_sha256) is malformed. It is a pre-check before any hashing comparison, ensuring hashes are canonical.
Solutions
- Recompute the hash with lowercase hex output: `sha256sum file | awk '{print $1}'` and put that 64-char value in the manifest
- Check for and remove uppercase letters — convert with `tr 'A-F' 'a-f'`
- Verify the field is not empty or truncated (exactly 64 characters)
- Strip whitespace/quotes around the value in the manifest JSON
Example fix
// before "sha256": "A3F1..." // after "sha256": "a3f1..."
Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_sha256(s: &str) -> bool {
s.len() == 64 && s.bytes().all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b))
}
if !is_valid_sha256(&theme.sha256) { return Err(InvalidThemeHash); } Type guard
fn as_sha256(s: &str) -> Option<&str> {
(s.len() == 64 && s.bytes().all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b))).then_some(s)
} Try / catch
match validate_market_theme(&theme) {
Err(e) if e.to_string().contains("无效 SHA-256") => regenerate_hash_and_retry(),
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Always generate hashes with lowercase hex output (sha256sum, hex::encode)
- Validate the hash field at manifest-creation time, before publishing
- Never hand-edit hash strings; copy them directly from tool output
When it happens
Trigger: Calling validate_market_theme with a theme whose sha256 field is empty, not 64 chars, contains uppercase hex (A-F), whitespace, '0x' prefix, or any non-lowercase-hex byte; verify_sha256 also calls it first on the expected value, so an invalid manifest hash triggers this instead of a checksum mismatch.
Common situations: Marketplace manifest generated by a tool emitting uppercase hex digests, hand-edited manifest with truncated hash, copy-paste introducing spaces/quotes, non-hash placeholder values in theme metadata.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- built-in Dream Skin theme cannot be deleted
- built-in Dream Skin theme is read-only
- current Dream Skin theme cannot be deleted
- Dream Skin theme name is empty
- 无效的主题市场相对路径
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/5664746214e3ae55.
Report an issue: GitHub.
Appendix: 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 b1ed92e5e4)