{"record":{"id":"384ada960525730b","repo":"ATH-MaaS/Pixelle-Video","slug":"dashscope-video-input-does-not-support-data-urls-i","errorCode":null,"errorMessage":"DashScope video input does not support data URLs in this adapter.","messagePattern":"DashScope video input does not support data URLs in this adapter\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/vlm_client.py","lineNumber":73,"sourceCode":"            print(\"-\" * 30)\n\n        if self.dashscope_client is None:\n            raise RuntimeError(\"DashScope VLM API key is not configured.\")\n\n        image_urls = [self._to_dashscope_file_url(path, allow_data_url=True) for path in image_paths or []]\n        video_urls = [self._to_dashscope_file_url(path, allow_data_url=False) for path in video_paths or []]\n        return self.dashscope_client.chat(\n            text=prompt,\n            images=image_urls,\n            videos=video_urls,\n            model=selected_model,\n            stream=False,\n        )\n\n    def _to_dashscope_file_url(self, path: str, allow_data_url: bool) -> str:\n        if path.startswith(\"data:\"):\n            if not allow_data_url:\n                raise ValueError(\"DashScope video input does not support data URLs in this adapter.\")\n\n            import base64 as b64\n            import tempfile\n\n            try:\n                header, b64_data = path.split(\",\", 1)\n                mime_type = header.split(\";\")[0].replace(\"data:\", \"\")\n                image_data = b64.b64decode(b64_data)\n                suffix = f\".{mime_type.split('/')[-1]}\" if \"/\" in mime_type else \".png\"\n                with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as tmp:\n                    tmp.write(image_data)\n                    temp_path = tmp.name\n                return f\"file://{os.path.abspath(temp_path)}\"\n            except Exception as e:\n                print(f\"Error processing base64 image: {e}\")\n                raise ValueError(f\"无法解析 base64 图片: {e}\")\n\n        if path.startswith(\"http\") or path.startswith(\"file://\"):","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/vlm_client.py#L55-L91","documentation":"_to_dashscope_file_url raises ValueError when a video path is a data: URL, because the adapter only allows data URLs for images (allow_data_url=True) and DashScope video input here requires an accessible file/http URL. Videos cannot be inlined as base64 data URLs in this adapter.","triggerScenarios":"Calling query(..., video_paths=[\"data:video/mp4;base64,...\"]) — the call to _to_dashscope_file_url(path, allow_data_url=False) rejects it.","commonSituations":"Pipeline that encodes all media to base64 data URLs for images reuses the same encoding for videos; upstream frame-extractor emits data URLs; code that worked with an image-only API extended to videos unchanged.","solutions":["Write the video bytes to a local file and pass the file path (the adapter converts it to file://...), or provide an http(s) URL","Decode the data URL yourself: base64-decode the payload after the comma into a .mp4 temp file","Adjust upstream producers to emit paths/URLs instead of data URLs for videos"],"exampleFix":"// before\nquery(prompt=p, video_paths=[\"data:video/mp4;base64,AAAA\"])\n// after\nimport base64, tempfile\nb64 = \"data:video/mp4;base64,AAAA\".split(\",\",1)[1]\nwith tempfile.NamedTemporaryFile(suffix=\".mp4\", delete=False) as f:\n    f.write(base64.b64decode(b64)); video_path = f.name\nquery(prompt=p, video_paths=[video_path])","handlingStrategy":"validation","validationCode":"def validate_video_inputs(video_paths):\n    for p in video_paths or []:\n        if p.startswith(\"data:\"):\n            raise ValueError(\"Videos must be local file paths or http(s) URLs, not data URLs\")","typeGuard":"def is_supported_video_input(p: str) -> bool:\n    return p.startswith((\"http://\", \"https://\", \"file://\")) or (not p.startswith(\"data:\") and __import__('os').path.isfile(p))","tryCatchPattern":"try:\n    answer = vlm.query(prompt=p, video_paths=videos, model=\"qwen-vl-max\")\nexcept ValueError as e:\n    if \"data URLs\" in str(e):\n        videos = [materialize_to_file(v) for v in videos]  # decode data URLs to temp files\n        answer = vlm.query(prompt=p, video_paths=videos, model=\"qwen-vl-max\")\n    else:\n        raise","preventionTips":["Encode only images as data URLs; always materialize videos to files or URLs","Add a pipeline-wide assertion that video inputs are paths/http URLs","Document the adapter limitation where video data URLs are produced"],"tags":["dashscope","vlm","data-url","video"],"backgroundTag":"unsupported-input-format","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}