sgl-project/sglang · error · ValueError

MiniMax H3 base64 decoded size {total} != expected {decoded_

Error message

MiniMax H3 base64 decoded size {total} != expected {decoded_size}

What it means

Internal consistency check: the total number of bytes produced by chunked decoding does not match the analytically computed expected decoded size. Indicates malformed base64 that decoded inconsistently, or a bug in the chunker.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/material_io.py:639

                if len(encoded_chunk) == MINIMAX_H3_BASE64_DECODE_CHUNK_CHARS:
                    decoded_chunk = _decode_base64_chunk(encoded_chunk)
                    total += len(decoded_chunk)
                    output.write(decoded_chunk)
                    encoded_chunk.clear()
            if encoded_size == 0:
                raise ValueError("material URI base64 payload is empty")
            if encoded_size % 4 == 1 or (padding and encoded_size % 4):
                raise ValueError("material URI has an invalid base64 payload length")
            if encoded_chunk:
                encoded_chunk.extend(b"=" * (-len(encoded_chunk) % 4))
                decoded_chunk = _decode_base64_chunk(encoded_chunk)
                total += len(decoded_chunk)
                output.write(decoded_chunk)
        decoded_size = (encoded_size * 3) // 4 - padding
        if decoded_size <= 0:
            raise ValueError("material URI decoded payload is empty")
        if total != decoded_size:
            raise ValueError(
                f"MiniMax H3 base64 decoded size {total} != expected {decoded_size}"
            )
        partial_path.replace(output_path)
    except Exception:
        partial_path.unlink(missing_ok=True)
        output_path.unlink(missing_ok=True)
        raise
    return str(output_path)


def _stream_tar_member_material(
    batch: Any,
    uri: str,
    *,
    condition_type: str,
    condition_index: int,
) -> str:
    source_path, offset, size, member = _parse_tar_member_uri(uri)

View on GitHub (pinned to 0132848349)

Solutions

  1. Re-encode the asset with the standard library to guarantee canonical base64
  2. If it persists with valid base64, report a bug with the payload length and chunk constants
  3. Verify MINIMAX_H3_BASE64_DECODE_CHUNK_CHARS was not modified
Defensive patterns

Strategy: try-catch

Try / catch

except ValueError as e: log payload metadata and file a bug — should be unreachable for canonical base64

Prevention

When it happens

Trigger: Malformed payload where per-chunk decode lengths sum to something other than (encoded_size*3)//4 - padding; should be unreachable for well-formed base64.

Common situations: Almost always a corrupted payload or a code change to _decode_base64_chunk / chunk constants; not typically a user config issue.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/bdfb6ecde064ca5a. Report an issue: GitHub.