ATH-MaaS/Pixelle-Video · error · RuntimeError
可灵任务成功但未返回视频数据 (task_id={task_id})
Error message
可灵任务成功但未返回视频数据 (task_id={task_id}) What it means
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.
Source
Thrown at pixelle_video/services/api_services/video_kling.py:395
task_id = self._submit_task(
image_path=image_path,
prompt=prompt,
negative_prompt=negative_prompt,
model_name=model,
mode=mode,
duration=str(duration),
cfg_scale=cfg_scale,
sound=sound,
aspect_ratio=aspect_ratio,
)
# 2. 轮询等待
result = self._poll_until_done(task_id, endpoint=endpoint)
# 3. 提取视频 URL
videos = result.get("task_result", {}).get("videos", [])
if not videos:
raise RuntimeError(f"可灵任务成功但未返回视频数据 (task_id={task_id})")
video_url = videos[0].get("url", "")
if not video_url:
raise RuntimeError(f"可灵任务成功但视频 URL 为空 (task_id={task_id})")
# 4. 下载到本地
self._download_video(video_url, save_path)
return video_url
if __name__ == "__main__":
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from config import Config
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
View on GitHub (pinned to 848b054e4f)
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.
Example fix
# before
videos = result.get("task_result", {}).get("videos", [])
# after
result_data = result.get("data", result) # 兼容不同包装层级
videos = (result_data.get("task_result") or {}).get("videos") or [] Defensive patterns
Strategy: type-guard
Type guard
def has_videos(result: dict) -> bool:
videos = (result.get("task_result") or {}).get("videos") or []
return len(videos) > 0 Try / catch
try:
url = client.generate_video(...)
except RuntimeError as e:
if "未返回视频数据" in str(e):
logger.error(f"成功但无视频载荷,疑似 schema 变更: {e}")
# 上报并检查 API 版本,必要时升级/降级客户端 Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- 可灵任务成功但视频 URL 为空 (task_id={task_id})
- Image edit failed: {response.code}, {response.message}, stat
- 万象视频任务完成后仍未返回 video_url: code={rsp.code}, message={rsp.messa
- 输入图片不存在: {image_path}
- 可灵 API 错误: code={data.get('code')}, message={data.get('messa
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/53bb9e706bfb4fee.
Report an issue: GitHub.