{"record":{"id":"a50675ee5163b79b","repo":"sgl-project/sglang","slug":"reference-image-target-dimensions-must-be-positive","errorCode":null,"errorMessage":"reference image target dimensions must be positive","messagePattern":"reference image target dimensions must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/reference_encoding.py","lineNumber":192,"sourceCode":"        \"rounding\": \"nearest\",\n        \"allow_upscale\": True,\n        \"width\": target_width,\n        \"height\": target_height,\n    }\n\n\ndef minimax_h3_resize_reference_image(\n    image: Any,\n    *,\n    target_width: int,\n    target_height: int,\n) -> Any:\n    \"\"\"Resize a reference image to the shape fixed by pre-queue admission.\"\"\"\n\n    from PIL import Image\n\n    if target_width <= 0 or target_height <= 0:\n        raise ValueError(\"reference image target dimensions must be positive\")\n    if (\n        target_width % MINIMAX_H3_REFERENCE_IMAGE_MULTIPLE\n        or target_height % MINIMAX_H3_REFERENCE_IMAGE_MULTIPLE\n    ):\n        raise ValueError(\n            \"reference image target dimensions must be aligned to \"\n            f\"{MINIMAX_H3_REFERENCE_IMAGE_MULTIPLE}\"\n        )\n    image = image.convert(\"RGB\")\n    if (target_width, target_height) == image.size:\n        return image\n    return image.resize((target_width, target_height), Image.Resampling.LANCZOS)\n\n\ndef _load_waveform(\n    path: str,\n    *,\n    material_chain: str = \"audio\",","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/reference_encoding.py#L174-L210","documentation":"The resize helper for MiniMax H3 reference images requires strictly positive integer target dimensions. It is normally fed dimensions produced by minimax_h3_resolve_reference_image_shape, so hitting this means the caller bypassed or corrupted the admission path.","triggerScenarios":"Calling minimax_h3_resize_reference_image / minimax_h3_prepared_reference_image directly with target_width or target_height <= 0, or hand-computing target dims that underflow to 0.","commonSituations":"Custom preprocessing code computing target dimensions with a bad scale factor (e.g. scale rounding to 0) instead of using the resolver's output.","solutions":["Use the (width,height) returned by minimax_h3_resolve_reference_image_shape rather than computing your own","Check for <=0 before calling and fall back to the resolver","If intercepting the pipeline, don't rewrite the prepared-image extra cache with zeroed dims"],"exampleFix":"// before\nimg = minimax_h3_resize_reference_image(img, 0, 512)\n\n// after\ntw, th = minimax_h3_resolve_reference_image_shape(img.size[0], img.size[1])\nimg = minimax_h3_resize_reference_image(img, tw, th)","handlingStrategy":"validation","validationCode":"def valid_target(w, h) -> bool:\n    return isinstance(w, int) and isinstance(h, int) and w > 0 and h > 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always take target dims from minimax_h3_resolve_reference_image_shape","Don't hand-roll scale math when calling the resize API"],"tags":["minimax-h3","resize","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}