{"record":{"id":"6119d871c349d3b9","repo":"sgl-project/sglang","slug":"unknown-visual-type-visual-type","errorCode":null,"errorMessage":"Unknown visual_type: {visual_type}","messagePattern":"Unknown visual_type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/mimo_v2.py","lineNumber":1296,"sourceCode":"            position_ids=position_ids,\n            rope_deltas=rope_deltas,\n            extra=extra,\n        )\n\n    def _flatten_visual_inputs(self, visual: torch.Tensor, visual_type: str):\n        if visual_type == \"image\":\n            resized_height, resized_width = visual.shape[-2:]\n            patches = visual.unsqueeze(0).repeat(self.temporal_patch_size, 1, 1, 1)\n        elif visual_type == \"video\" or visual_type == \"video_audio\":\n            assert (\n                len(visual)\n                % (self.temporal_compression_ratio * self.temporal_patch_size)\n                == 0\n            )\n            patches = visual\n            resized_height, resized_width = patches.shape[-2:]\n        else:\n            raise ValueError(f\"Unknown visual_type: {visual_type}\")\n\n        channel = patches.shape[1]\n        grid_t = patches.shape[0] // self.temporal_patch_size\n        grid_h, grid_w = (\n            resized_height // self.patch_size,\n            resized_width // self.patch_size,\n        )\n        patches = patches.contiguous().view(\n            grid_t,\n            self.temporal_patch_size,\n            channel,\n            grid_h // self.merge_size,\n            self.merge_size,\n            self.patch_size,\n            grid_w // self.merge_size,\n            self.merge_size,\n            self.patch_size,\n        )","sourceCodeStart":1278,"sourceCodeEnd":1314,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/mimo_v2.py#L1278-L1314","documentation":"Raised in _flatten_visual_inputs when visual_type doesn't match any known branch of the flatten dispatch. The function reshapes visual patches for image vs video visual types; anything else (unknown string, typo'd enum) falls through to this ValueError.","triggerScenarios":"Calling _flatten_visual_inputs (directly or via preprocess_for_encoder/process_video/_process_image_content) with a visual_type string that isn't one of the handled image/video keys — e.g. 'audio', an outdated name, or a custom value.","commonSituations":"Version skew where a newer/older sglang defines different visual_type keys than the model code passing them; internal refactors renaming visual type constants; custom multimodal extensions introducing new visual kinds without extending the dispatcher.","solutions":["Check the visual_type value in the message against the keys handled in _flatten_visual_inputs in your sglang version","Ensure sglang and any custom model code are the same version so visual type constants match","Route only image/video visuals through this path; audio has its own preprocessing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"assert visual_type in ('image', 'video'), f'unknown visual_type {visual_type!r} for this sglang version'","typeGuard":"def is_known_visual_type(t: str) -> bool:\n    return t in {'image', 'video'}  # keep in sync with _flatten_visual_inputs branches","tryCatchPattern":"try:\n    flat = proc._flatten_visual_inputs(visual, visual_type)\nexcept ValueError as e:\n    if 'Unknown visual_type' in str(e):\n        raise Http400(f'visual_type {visual_type!r} not supported by model version')\n    raise","preventionTips":["Pin matching sglang + model code versions","Route audio through its own preprocessing, never the visual flattener","Add integration tests covering each visual_type you use"],"tags":["visual","dispatch","input-validation","version-skew"],"backgroundTag":"unknown-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}