Comfy-Org/ComfyUI · error · ValueError
INVALID_HASH
INVALID_HASH
Error message
hash must be 'blake3:<hex>'
What it means
First failure mode of validate_blake3_hash in app/assets/helpers.py: the input (after strip+lower) is empty or contains no ':' separator, so it cannot be an 'algo:digest' string. The function's contract is to return a canonical 'blake3:<64-hex>' string or raise ValueError.
Source
Thrown at app/assets/helpers.py:57
def normalize_tags(tags: list[str] | None) -> list[str]:
"""
Normalize a list of tags by:
- Stripping whitespace.
- Removing exact duplicates while preserving order and case.
"""
return list(dict.fromkeys(t.strip() for t in (tags or []) if (t or "").strip()))
def validate_blake3_hash(s: str) -> str:
"""Validate and normalize a blake3 hash string.
Returns canonical 'blake3:<hex>' or raises ValueError.
"""
s = s.strip().lower()
if not s or ":" not in s:
raise ValueError("hash must be 'blake3:<hex>'")
algo, digest = s.split(":", 1)
if (
algo != "blake3"
or len(digest) != 64
or any(c for c in digest if c not in "0123456789abcdef")
):
raise ValueError("hash must be 'blake3:<hex>'")
return f"{algo}:{digest}"
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Prefix the digest: send 'blake3:<hex>' with exactly 64 lowercase hex characters.
- If you hold a bare digest, construct the canonical form before calling: f"blake3:{digest}".
- Validate the shape client-side with a regex before submitting.
- Map the ValueError to 400 INVALID_HASH at the API boundary.
Example fix
// before
validate_blake3_hash(digest_hex) # e.g. "af12..." no prefix
// after
validate_blake3_hash(f"blake3:{digest_hex}") Defensive patterns
Strategy: validation
Validate before calling
import re
def looks_like_blake3(s: str) -> bool:
return re.fullmatch(r"\s*blake3:[0-9a-fA-F]{64}\s*", s or "") is not None Try / catch
try:
canonical = validate_blake3_hash(raw)
except ValueError as e:
raise HTTPException(status_code=400, detail={"code": "INVALID_HASH", "message": str(e)}) Prevention
- Always store and send hashes as 'blake3:<64 hex>'; wrap bare digests with f"blake3:{digest}".
- Validate the shape with a regex before submission.
- Remember the function lowercases input, so case alone never fails.
When it happens
Trigger: Passing a bare 64-character hex digest with no 'blake3:' prefix, an empty/whitespace string, or any string without a colon — e.g. ingest APIs receiving the raw hasher output instead of the prefixed form.
Common situations: Clients that compute blake3 locally and send just the hex digest; config files or JSON payloads storing the hash without the algorithm prefix; copy-pasting only the digest half of a stored hash.
Related errors
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/5ad80565421f94fb.
Report an issue: GitHub.