{"record":{"id":"53bb9e706bfb4fee","repo":"ATH-MaaS/Pixelle-Video","slug":"task-id-task-id","errorCode":null,"errorMessage":"可灵任务成功但未返回视频数据 (task_id={task_id})","messagePattern":"可灵任务成功但未返回视频数据 \\(task_id=(.+?)\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/video_kling.py","lineNumber":395,"sourceCode":"        task_id = self._submit_task(\n            image_path=image_path,\n            prompt=prompt,\n            negative_prompt=negative_prompt,\n            model_name=model,\n            mode=mode,\n            duration=str(duration),\n            cfg_scale=cfg_scale,\n            sound=sound,\n            aspect_ratio=aspect_ratio,\n        )\n\n        # 2. 轮询等待\n        result = self._poll_until_done(task_id, endpoint=endpoint)\n\n        # 3. 提取视频 URL\n        videos = result.get(\"task_result\", {}).get(\"videos\", [])\n        if not videos:\n            raise RuntimeError(f\"可灵任务成功但未返回视频数据 (task_id={task_id})\")\n\n        video_url = videos[0].get(\"url\", \"\")\n        if not video_url:\n            raise RuntimeError(f\"可灵任务成功但视频 URL 为空 (task_id={task_id})\")\n\n        # 4. 下载到本地\n        self._download_video(video_url, save_path)\n\n        return video_url\n\n\nif __name__ == \"__main__\":\n    import sys\n    sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n    from config import Config\n\n    logging.basicConfig(level=logging.INFO, format=\"%(asctime)s %(levelname)s %(message)s\")\n","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/video_kling.py#L377-L413","documentation":"The Kling task reported 'succeed', but the response's task_result contains no videos array. generate_video treats a success status without video entries as a contract violation and raises RuntimeError, since there is nothing to download.","triggerScenarios":"After _poll_until_done returns, result.get('task_result', {}).get('videos', []) is empty (video_kling.py:394-395) — Kling returned success but omitted the video payload, usually due to an undocumented API response-shape change, partial success, or SDK/proxy mangling the body.","commonSituations":"Kling API version update altering the response schema (e.g. nesting videos differently), a proxy/CDN truncating the JSON, or tasks that succeed with zero outputs in edge cases (degenerate inputs).","solutions":["Log the full `result` dict to see the actual response shape; if Kling moved the videos field, update the extraction path accordingly.","Pin/upgrade to the Kling API version whose schema matches the extraction code, and re-test with a simple image2video request.","Disable any intermediary proxy/response rewriting and confirm the raw JSON contains task_result.videos.","Retry generation once — if it reproduces on every success, it is a schema issue, not a transient one."],"exampleFix":"# before\nvideos = result.get(\"task_result\", {}).get(\"videos\", [])\n# after\nresult_data = result.get(\"data\", result)  # 兼容不同包装层级\nvideos = (result_data.get(\"task_result\") or {}).get(\"videos\") or []","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def has_videos(result: dict) -> bool:\n    videos = (result.get(\"task_result\") or {}).get(\"videos\") or []\n    return len(videos) > 0","tryCatchPattern":"try:\n    url = client.generate_video(...)\nexcept RuntimeError as e:\n    if \"未返回视频数据\" in str(e):\n        logger.error(f\"成功但无视频载荷，疑似 schema 变更: {e}\")\n        # 上报并检查 API 版本，必要时升级/降级客户端","preventionTips":["Pin the Kling API version and re-verify response schema after any change","Log full task_result payloads in non-production to catch schema drift early","Add an integration test asserting task_result.videos is non-empty on success","Bypass proxies that may rewrite/truncate JSON bodies"],"tags":["kling","missing-video","schema-change","api-response"],"backgroundTag":"task-completed-no-result-url","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}