calesthio/OpenMontage · error · KlingAPIError
Kling Turbo poll response missing data[0]: {data}
Error message
Kling Turbo poll response missing data[0]: {data} What it means
Raised when the Turbo poll GET /tasks?task_ids=<id> returns an empty (or non-list) data array. poll_turbo() immediately indexes records[0] after the emptiness check, so a first poll that arrives before the task registry has indexed the new task fails instead of waiting.
Source
Thrown at tools/_kling/client.py:121
def create_turbo(self, path: str, payload: dict[str, Any]) -> str:
data = self.post(path, payload)
task_id = ((data.get("data") or {}).get("id"))
if not task_id:
raise KlingAPIError(f"Kling Turbo create response missing data.id: {data}")
return str(task_id)
def poll_turbo(
self,
task_id: str,
timeout_seconds: int = 900,
poll_interval: float = 5.0,
) -> list[dict[str, Any]]:
deadline = time.time() + timeout_seconds
while time.time() < deadline:
data = self.get("/tasks", params={"task_ids": task_id})
records = data.get("data") or []
if not records:
raise KlingAPIError(f"Kling Turbo poll response missing data[0]: {data}")
record = records[0]
status = record.get("status") or record.get("task_status")
if status == TURBO_SUCCESS_STATUS:
outputs = record.get("outputs") or []
if not isinstance(outputs, list):
raise KlingAPIError("Kling Turbo result path data[0].outputs is not a list")
return outputs
if status == TURBO_FAILURE_STATUS:
message = record.get("message") or record.get("error") or "Kling Turbo task failed"
raise KlingAPIError(str(message), code=record.get("code"), request_id=record.get("request_id"), response=data)
if status not in TURBO_PENDING_STATUSES:
raise KlingAPIError(f"Unexpected Kling Turbo task status {status!r}", response=data)
time.sleep(min(poll_interval, max(0.0, deadline - time.time())))
raise TimeoutError(f"Kling Turbo task {task_id} timed out after {timeout_seconds}s")
def _request(self, method: str, path: str, **kwargs: Any) -> dict[str, Any]:
url = self._url(path)
last_error: KlingAPIError | None = NoneView on GitHub (pinned to 95e1c3d0ab)
Solutions
- Add a short initial delay (2–5s) between create_turbo() and poll_turbo()
- Verify base_url and task_id belong to the same deployment
- If the gateway is eventually consistent, tolerate empty data for the first few polls before raising
- Confirm the task_id string was not truncated or transformed
Example fix
// before task_id = client.create_turbo(path, payload) outputs = client.poll_turbo(task_id) // after import time task_id = client.create_turbo(path, payload) time.sleep(5) # let the task registry index the new task outputs = client.poll_turbo(task_id)
Defensive patterns
Strategy: retry
Validate before calling
def turbo_task_visible(client, task_id: str) -> bool:
data = client.get('/tasks', params={'task_ids': task_id})
return bool(data.get('data')) Try / catch
from tools._kling.errors import KlingAPIError
for attempt in range(3):
try:
outputs = client.poll_turbo(task_id)
break
except KlingAPIError as e:
if 'missing data[0]' not in str(e) or attempt == 2:
raise
time.sleep(3) # registry propagation delay, then re-poll Prevention
- Sleep 2-5s between create_turbo() and the first poll_turbo() call
- Keep create and poll on the same base_url/deployment
- Treat an empty first poll as 'not yet visible', not as task failure
When it happens
Trigger: Polling immediately after create_turbo() and the backend has not yet registered the task (eventual-consistency delay); querying with a task_id from a different base_url/deployment where it does not exist; the gateway filtering out tasks owned by another API key.
Common situations: Race between create and first poll on a load-balanced Turbo gateway; wrong region base URL so the task_id is unknown; task already expired and pruned from the registry.
Related errors
- Unexpected Kling Turbo task status {status!r}
- Kling Turbo task {task_id} timed out after {timeout_seconds}
- Kling Classic task failed
- Unexpected Kling Classic task status {status!r}
- Kling Classic task {task_id} timed out after {timeout_second
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/ef88ddb498654d03.
Report an issue: GitHub.