{"record":{"id":"38a23ceb3d10f55a","repo":"sgl-project/sglang","slug":"incorrect-type-of-image-sizes-got-type-type-ima-38a23c","errorCode":null,"errorMessage":"Incorrect type of image sizes. Got type: {type(images_spatial_crop)}","messagePattern":"Incorrect type of image sizes\\. Got type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/unlimited_ocr.py","lineNumber":187,"sourceCode":"        images_spatial_crop = kwargs.pop(\"images_spatial_crop\", None)\n        images_crop = kwargs.pop(\"images_crop\", None)\n        has_images = kwargs.pop(\"has_images\", None)\n\n        if pixel_values is None:\n            return None\n        if has_images is not None:\n            if not has_images:\n                return None\n        elif torch.sum(pixel_values).item() == 0:\n            return None\n\n        if pixel_values is not None:\n            if not isinstance(pixel_values, (torch.Tensor, list)):\n                raise ValueError(\n                    \"Incorrect type of pixel values. \" f\"Got type: {type(pixel_values)}\"\n                )\n            if not isinstance(images_spatial_crop, (torch.Tensor, list)):\n                raise ValueError(\n                    \"Incorrect type of image sizes. \"\n                    f\"Got type: {type(images_spatial_crop)}\"\n                )\n            if not isinstance(images_crop, (torch.Tensor, list)):\n                raise ValueError(\n                    \"Incorrect type of image crop. \" f\"Got type: {type(images_crop)}\"\n                )\n            return [pixel_values, images_crop, images_spatial_crop]\n\n        raise AssertionError(\"This line should be unreachable.\")\n\n    def _pixel_values_to_embedding(\n        self,\n        pixel_values: torch.Tensor,\n        images_crop: torch.Tensor,\n        images_spatial_crop: torch.Tensor,\n        has_local_crops: Optional[List[bool]] = None,\n    ) -> NestedTensors:","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/unlimited_ocr.py#L169-L205","documentation":"Companion guard to 5637: images_spatial_crop must be a torch.Tensor or list; other types raise with the offending type in the message.","triggerScenarios":"Supplying images_spatial_crop as numpy array or omitted/wrong object while pixel_values is present.","commonSituations":"Custom request payloads lacking spatial crop metadata or providing numpy formats; processor version changes renaming the field.","solutions":["Ensure the processor supplies images_spatial_crop as tensor/list alongside pixel_values","Convert numpy inputs to torch tensors","Use the standard sglang multimodal processor path instead of manual payloads"],"exampleFix":"# before\nspatial_crop=np.array([[2,2]])\n# after\nspatial_crop=torch.tensor([[2,2]])","handlingStrategy":"type-guard","validationCode":"assert images_spatial_crop is None or isinstance(images_spatial_crop, (torch.Tensor, list))","typeGuard":"def valid_spatial_crop(s):\n    return s is None or isinstance(s, (torch.Tensor, list))","tryCatchPattern":null,"preventionTips":["Build all image fields through one processor call","Type-check payloads in tests"],"tags":["type-validation","multimodal","spatial-crop"],"backgroundTag":"invalid-input-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}