unslothai/unsloth · error · ValueError
A reference decoded to no data.
Error message
A reference decoded to no data.
What it means
The reference payload was syntactically valid base64 but decoded to zero bytes (e.g. the empty string is technically valid base64). _decode_b64_media treats a zero-length blob as an error distinct from 'invalid base64' and from 'empty input', catching data URLs like 'data:image/png;base64,' whose payload part is blank.
Source
Thrown at studio/backend/core/inference/video.py:423
_MAX_REFERENCE_MEDIA_BYTES = 96 * 1024 * 1024
def _decode_b64_media(data: Optional[str]) -> bytes:
"""Decode a base64 media payload, optionally wrapped in a data URL."""
import base64
import binascii
raw = (data or "").strip()
if not raw:
raise ValueError("A reference was sent empty.")
if raw.startswith("data:"):
_, _, raw = raw.partition(",")
try:
blob = base64.b64decode(raw, validate = False)
except (binascii.Error, ValueError) as exc:
raise ValueError(f"Invalid base64 media data: {exc}") from exc
if not blob:
raise ValueError("A reference decoded to no data.")
if len(blob) > _MAX_REFERENCE_MEDIA_BYTES:
raise ValueError(
f"A reference is too large ({len(blob) / 1e6:.0f} MB); the limit is "
f"{_MAX_REFERENCE_MEDIA_BYTES / 1e6:.0f} MB."
)
return blob
class _VideoGenerationCancelled(Exception):
"""Unwinds a denoise loop that has no cooperative interrupt (no step callback);
generate() maps it to the VIDEO_CANCELLED_MSG sentinel the routes 409 on."""
@contextlib.contextmanager
def _scheduler_step_progress(pipe: Any, on_step: Any):
"""Progress + cancellation for pipelines WITHOUT callback_on_step_end.
HunyuanVideo15Pipeline exposes no per-step callback, but every denoise stepView on GitHub (pinned to 203007d190)
Solutions
- Ensure the media blob is actually read and non-empty before encoding it.
- Skip sending the reference entirely when the source file/blob is zero-length.
- If the field is optional, omit the key rather than sending an empty wrapper.
Example fix
# before
ref = f'data:image/png;base64,{b64}' # b64 == '' for a missing file
# after
ref = f'data:image/png;base64,{b64}' if b64 else None
# and omit the field when ref is None Defensive patterns
Strategy: validation
Validate before calling
import base64
def decodes_to_data(ref: str | None) -> bool:
if not ref or not ref.strip():
return False
raw = ref.strip()
if raw.startswith('data:'):
raw = raw.partition(',')[2]
try:
return len(base64.b64decode(raw)) > 0
except Exception:
return False Type guard
def nonempty_b64_payload(value: str) -> bool:
raw = value.strip()
if raw.startswith('data:'):
raw = raw.partition(',')[2]
return len(raw) > 0 and base64.b64decode(raw, validate=False) != b'' Try / catch
try:
blob = _decode_b64_media(ref)
except ValueError as e:
if 'decoded to no data' in str(e):
ref = capture_fallback_or_none() # re-capture the source media
else:
raise Prevention
- Check the source blob's byte length before encoding it.
- Never emit the data-URL wrapper when the underlying read returned nothing.
- Treat zero-byte uploads as 'no file provided' in the UI.
When it happens
Trigger: Sending a data URL whose comma-separated payload is empty, or a bare base64 of b'' (empty string). The earlier empty check only fires on whitespace-only input, so a well-formed wrapper around nothing reaches this branch.
Common situations: A UI that always emits the data-URL wrapper even for a missing file; canvas/ImageBlob.toDataURL() on an unrendered element; a truncated upload where the encoder produced the header but no body.
Related errors
- each reference must be at most 32 MiB (base64)
- A reference was sent empty.
- Invalid base64 media data: {exc}
- Invalid base64 image data: {exc}
- Unknown model_kind '{model_kind}'. Expected one of {sorted(_
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/fc1573319a89d36e.
Report an issue: GitHub.