ATH-MaaS/Pixelle-Video · error · RuntimeError

Seedance API 未返回任务 ID: {data}

Error message

Seedance API 未返回任务 ID: {data}

What it means

_submit_task raises RuntimeError when the Seedance API returns a 2xx response whose JSON body lacks an 'id' field, so no task can be polled. The client treats a missing task ID as an unexpected/malformed API response.

Source

Thrown at pixelle_video/services/api_services/video_seedance.py:140

                payload[key] = kwargs[key]

        logger.info(f"SeedanceVideoClient: 提交任务 model={model}, duration={duration}s")
        resp = requests.post(
            url,
            headers=self._headers(),
            json=payload,
            timeout=self.timeout,
            proxies=self._proxies(),
        )
        
        if not resp.ok:
            logger.error(f"Seedance 提交失败: {resp.text}")
            resp.raise_for_status()
            
        data = resp.json()
        task_id = data.get("id")
        if not task_id:
            raise RuntimeError(f"Seedance API 未返回任务 ID: {data}")
            
        return task_id

    def _poll_until_done(self, task_id: str, max_polls: int = 120, interval: int = 5) -> str:
        # 同步更新查询接口路径
        url = f"{self.base_url}/contents/generations/tasks/{task_id}"
        
        for i in range(max_polls):
            resp = requests.get(url, headers=self._headers(), timeout=30, proxies=self._proxies())
            resp.raise_for_status()
            data = resp.json()
            
            status = data.get("status")
            if status == "succeeded":
                # 根据实际返回体,URL 位于 content.video_url 或 video_url
                video_url = data.get("content", {}).get("video_url") or data.get("video_url")
                if not video_url:
                    raise RuntimeError(f"Seedance 任务成功但未返回视频 URL: {data}")

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Log the full response body (it is embedded in the exception message) and inspect the actual JSON structure
  2. Verify ARK_API_KEY validity, quota and billing on the Volcano Engine console
  3. Confirm base_url matches the current Seedance API endpoint/version
  4. If the API nests the ID (e.g. data['result']['id']), adjust the client's data.get("id") accordingly

Example fix

// before
task_id = data.get("id")
// after
task_id = data.get("id") or (data.get("result") or {}).get("id") or data.get("task_id")
Defensive patterns

Strategy: try-catch

Try / catch

try:
    video = client.generate_video(prompt=p, image_path=img, save_path=out)
except RuntimeError as e:
    if "未返回任务 ID" in str(e):
        logging.error(f"Seedance submit returned no task id: {e}")  # inspect body, check key/quota
    else:
        raise

Prevention

When it happens

Trigger: POST to the task-submission endpoint returns success HTTP status but body has no 'id' — e.g. wrong endpoint version, an error payload returned with 200, or auth/billing errors shaped differently than expected.

Common situations: Expired or quota-exhausted API key returning an error body with HTTP 200; API contract changed; pointing base_url at a proxy/mock that returns different JSON; region-specific endpoints returning a different envelope.

Related errors


AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/9423463f03fe8eb4. Report an issue: GitHub.