{"record":{"id":"61b433f3bf6677cc","repo":"sgl-project/sglang","slug":"incorrect-type-of-image-crop-got-type-type-imag-61b433","errorCode":null,"errorMessage":"Incorrect type of image crop. Got type: {type(images_crop)}","messagePattern":"Incorrect type of image crop\\. Got type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/unlimited_ocr.py","lineNumber":192,"sourceCode":"            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:\n        \"\"\"Encode pixel values into per-image embedding sequences.\"\"\"\n        images_in_this_batch = []\n\n        with torch.no_grad():\n            for jdx in range(images_spatial_crop.size(0)):","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/unlimited_ocr.py#L174-L210","documentation":"Third guard in the same validation chain: images_crop must be a torch.Tensor or list, otherwise the input is rejected.","triggerScenarios":"Passing images_crop of an unsupported type (e.g. numpy) with image inputs to UnlimitedOCR's get_multimodal_embeddings.","commonSituations":"Manual multimodal input construction bypassing the processor; format drift between preprocessing and serving layers.","solutions":["Convert images_crop to a torch tensor or list before calling","Rely on the built-in multimodal processor to build all three fields consistently","Validate the whole image-input dict before forwarding"],"exampleFix":"# before\nimages_crop=np_crops\n# after\nimages_crop=torch.from_numpy(np_crops)","handlingStrategy":"type-guard","validationCode":"assert images_crop is None or isinstance(images_crop, (torch.Tensor, list))","typeGuard":"def valid_crop(c):\n    return c is None or isinstance(c, (torch.Tensor, list))","tryCatchPattern":null,"preventionTips":["Standardize on torch tensors end-to-end","Add schema checks for manual multimodal payloads"],"tags":["type-validation","multimodal","image-crop"],"backgroundTag":"invalid-input-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}