{"record":{"id":"b71e41ddb586f602","repo":"sgl-project/sglang","slug":"material-uri-base64-payload-is-empty","errorCode":null,"errorMessage":"material URI base64 payload is empty","messagePattern":"material URI base64 payload is empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/material_io.py","lineNumber":627,"sourceCode":"    try:\n        with partial_path.open(\"wb\") as output:\n            for value in _iter_base64_payload_bytes(uri, payload_start):\n                encoded_size += 1\n                if value == ord(\"=\"):\n                    saw_padding = True\n                    padding += 1\n                    if padding > 2:\n                        raise ValueError(\"material URI has invalid base64 padding\")\n                elif saw_padding:\n                    raise ValueError(\"material URI has data after base64 padding\")\n                encoded_chunk.append(value)\n                if len(encoded_chunk) == MINIMAX_H3_BASE64_DECODE_CHUNK_CHARS:\n                    decoded_chunk = _decode_base64_chunk(encoded_chunk)\n                    total += len(decoded_chunk)\n                    output.write(decoded_chunk)\n                    encoded_chunk.clear()\n            if encoded_size == 0:\n                raise ValueError(\"material URI base64 payload is empty\")\n            if encoded_size % 4 == 1 or (padding and encoded_size % 4):\n                raise ValueError(\"material URI has an invalid base64 payload length\")\n            if encoded_chunk:\n                encoded_chunk.extend(b\"=\" * (-len(encoded_chunk) % 4))\n                decoded_chunk = _decode_base64_chunk(encoded_chunk)\n                total += len(decoded_chunk)\n                output.write(decoded_chunk)\n        decoded_size = (encoded_size * 3) // 4 - padding\n        if decoded_size <= 0:\n            raise ValueError(\"material URI decoded payload is empty\")\n        if total != decoded_size:\n            raise ValueError(\n                f\"MiniMax H3 base64 decoded size {total} != expected {decoded_size}\"\n            )\n        partial_path.replace(output_path)\n    except Exception:\n        partial_path.unlink(missing_ok=True)\n        output_path.unlink(missing_ok=True)","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/material_io.py#L609-L645","documentation":"The base64 payload of a data/base64 material URI decoded to zero encoded characters, so there is nothing to write. The streaming decoder requires a non-empty payload.","triggerScenarios":"minimax_h3_localize_material_uri receives 'data:image/png;base64,' or 'base64:' with nothing after the scheme prefix.","commonSituations":"Empty file encoded as a data URI, template bug producing an empty payload variable, upstream truncation of the URI string.","solutions":["Check the caller that produced the URI and fix the empty payload","Fall back to a local file:// path if the asset exists on disk","Log the raw URI length before passing it to the pipeline"],"exampleFix":"# before\nuri = f\"data:{mime};base64,{payload}\"  # payload == ''\n# after\nif not payload:\n    raise ValueError(\"empty asset\")\nuri = f\"data:{mime};base64,{payload}\"","handlingStrategy":"validation","validationCode":"payload = uri.split(',', 1)[-1]\nassert payload, 'empty base64 payload'","typeGuard":null,"tryCatchPattern":"try:\n    minimax_h3_localize_material_uri(batch, uri, ...)\nexcept ValueError as e:\n    if 'empty' in str(e): skip_or_reject(uri)","preventionTips":["Check payload non-empty before building data URIs","Log URI lengths at the request boundary"],"tags":["base64","empty-payload","minimax-h3"],"backgroundTag":"empty-request-payload","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}