{"record":{"id":"1fe92bb0cb495f3c","repo":"sgl-project/sglang","slug":"unsupported-video-input-type-type-video-file","errorCode":null,"errorMessage":"Unsupported video input type: {type(video_file)}","messagePattern":"Unsupported video input type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/common.py","lineNumber":1957,"sourceCode":"            return video_file\n        else:\n            return pybase64.b64decode(video_file, validate=True)\n    else:\n        return None\n\n\ndef get_video_bytes(video_file: Union[str, bytes, VideoData]) -> bytes:\n    \"\"\"Normalize a video input and return its encoded bytes.\"\"\"\n    if isinstance(video_file, VideoData):\n        video_file = video_file.url\n\n    source = _normalize_video_input(video_file)\n    if isinstance(source, bytes):\n        return source\n    if isinstance(source, str):\n        with open(source, \"rb\") as f:\n            return f.read()\n    raise ValueError(f\"Unsupported video input type: {type(video_file)}\")\n\n\ndef load_video(video_file: Union[str, bytes, VideoData], use_gpu: bool = True):\n    if isinstance(video_file, VideoData):\n        # preprocess_kwargs is consumed by the multimodal processor, not here.\n        video_file = video_file.url\n\n    if isinstance(video_file, (list, tuple, torch.Tensor, np.ndarray)):\n        return video_file\n\n    source = _normalize_video_input(video_file)\n    if source is None:\n        raise ValueError(f\"Unsupported video input type: {type(video_file)}\")\n\n    device = \"cuda\" if use_gpu else \"cpu\"\n    try:\n        return VideoDecoderWrapper(source, device=device)\n    except (ImportError, MemoryError):","sourceCodeStart":1939,"sourceCodeEnd":1975,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/common.py#L1939-L1975","documentation":"Raised by the video-bytes loader when the normalized video input is neither bytes nor a filesystem path string. The loader can only return raw bytes for str/bytes/VideoData.url inputs; anything else (e.g. a tensor, list, None, dict) falls through to this ValueError.","triggerScenarios":"Calling load_video_bytes (or an API that routes through it) with a video payload that is not a path string, raw bytes, or a VideoData whose .url normalizes to one of those — e.g. passing a pre-decoded tensor/list of frames or None.","commonSituations":"Multimodal request payloads where the client sends frames/tensors instead of a URL/path, or a VideoData without a url; version changes that changed accepted video input types.","solutions":["Pass a local file path string or raw bytes for the video","If you have a VideoData object, ensure its url field is set to a path/URL that _normalize_video_input accepts","Pre-decoded frame tensors/lists should go through load_video (which accepts them), not the bytes loader"],"exampleFix":"// before\nvideo_bytes = load_video_bytes(video_file)  # video_file is a list[np.ndarray]\n// after\nvideo_bytes = load_video_bytes(str(video_path))  # or pass bytes","handlingStrategy":"type-guard","validationCode":"from pathlib import Path\nok = isinstance(v, (str, bytes)) or (hasattr(v, \"url\") and isinstance(v.url, (str, bytes)))","typeGuard":"def is_loadable_video_bytes(v) -> bool:\n    return isinstance(v, (str, bytes)) or (getattr(v, \"url\", None) is not None and isinstance(v.url, (str, bytes)))","tryCatchPattern":null,"preventionTips":["Validate multimodal request video fields against the accepted type union at the API boundary","Pre-decoded frames go to load_video, not the bytes loader"],"tags":["video","multimodal","input-validation","valueerror"],"backgroundTag":"unsupported-input-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}