calesthio/OpenMontage · error · ValueError

invalid base64 in {label} Data URI

Error message

invalid base64 in {label} Data URI

What it means

Error "invalid base64 in {label} Data URI" thrown in calesthio/OpenMontage.

Source

Thrown at tools/video/seedance_ark.py:1118

        label: str,
    ) -> tuple[str, bytes]:
        match = re.fullmatch(
            r"data:([a-z]+/[a-z0-9.+-]+);base64,([A-Za-z0-9+/=]+)",
            value,
            flags=re.IGNORECASE,
        )
        if not match:
            raise ValueError(
                f"{label} Data URI must use a supported MIME type and "
                "strict base64 encoding"
            )
        mime = match.group(1).lower()
        if mime not in set(suffix_to_mime.values()):
            raise ValueError(f"unsupported {label} Data URI MIME type: {mime}")
        try:
            decoded = base64.b64decode(match.group(2), validate=True)
        except (ValueError, binascii.Error) as exc:
            raise ValueError(f"invalid base64 in {label} Data URI") from exc
        if len(decoded) >= max_bytes:
            raise ValueError(
                f"decoded {label} Data URI must be smaller than "
                f"{max_bytes // (1024 * 1024)} MB"
            )
        return mime, decoded

    def _local_or_data_audio_duration(
        self, value: str, *, max_seconds: int = 15
    ) -> float | None:
        if value.startswith("data:"):
            mime, decoded = self._decode_data_uri(
                value,
                suffix_to_mime=self.AUDIO_SUFFIX_TO_MIME,
                max_bytes=self.MAX_AUDIO_BYTES,
                label="audio",
            )
            return self._probe_audio_bytes(decoded, mime, max_seconds=max_seconds)

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Re-encode the payload with standard base64 (padding included, no newlines).
  2. If building the URI manually, use base64.b64encode(data).decode() rather than urlsafe variants.

When it happens

Trigger: The base64 payload of a reference Data URI fails strict decoding.

Common situations: See trigger scenarios.


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/45f3bddf25c9d9b6. Report an issue: GitHub.