{"record":{"id":"476b0de63b213928","repo":"MiniMax-AI/skills","slug":"timeout-after-max-wait-s-task-id-task-id-chec-476b0d","errorCode":null,"errorMessage":"Timeout after {max_wait}s. task_id={task_id}, check manually.","messagePattern":"Timeout after (.+?)s\\. task_id=(.+?), check manually\\.","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"warning","filePath":"skills/gif-sticker-maker/scripts/minimax_video.py","lineNumber":143,"sourceCode":"        data = resp.json()\n        _check_resp(data)\n\n        status = data.get(\"status\", \"\")\n        file_id = data.get(\"file_id\", \"\")\n\n        if status == \"Success\":\n            if not file_id:\n                raise SystemExit(\"Task succeeded but no file_id returned\")\n            print(f\"  Done! file_id={file_id}\")\n            return file_id\n        elif status == \"Fail\":\n            raise SystemExit(f\"Video generation failed: {json.dumps(data, indent=2)}\")\n        else:\n            print(f\"  [{elapsed}s] Status: {status}...\")\n            time.sleep(interval)\n            elapsed += interval\n\n    raise SystemExit(f\"Timeout after {max_wait}s. task_id={task_id}, check manually.\")\n\n\ndef download_video(file_id: str, output_path: str):\n    \"\"\"Retrieve download URL via file_id and save the video.\"\"\"\n    resp = requests.get(\n        f\"{API_BASE}/files/retrieve\",\n        headers=_headers(),\n        params={\"file_id\": file_id},\n        timeout=30,\n    )\n    resp.raise_for_status()\n    data = resp.json()\n    _check_resp(data)\n\n    download_url = data.get(\"file\", {}).get(\"download_url\", \"\")\n    if not download_url:\n        raise SystemExit(f\"No download_url in response: {json.dumps(data, indent=2)}\")\n","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/gif-sticker-maker/scripts/minimax_video.py#L125-L161","documentation":"poll_task() looped until elapsed >= max_wait (default 600s) without reaching Success or Fail. The task may still be processing server-side; the task_id is included so it can be queried/resumed manually later.","triggerScenarios":"Video generation takes longer than max_wait — queue backlog, high resolution (1080P), long duration (10s), or peak-hour congestion inflate processing time beyond the default 600s.","commonSituations":"Default 600s too short for 1080P/10s jobs; server-side queue slow at peak hours; network latency inflating each poll round.","solutions":["Re-run with --max-wait 1200 (or pass max_wait=1200).","Manually query the task_id later via GET /query/video_generation?task_id=... and then download_video() once Success.","Lower resolution to 768P/720P or duration to 6s to speed processing.","Persist the task_id so a timed-out run can be resumed without re-submitting."],"exampleFix":"# before\nfile_id = poll_task(task_id)  # default max_wait=600 -> Timeout\n\n# after\nfile_id = poll_task(task_id, max_wait=1800, interval=15)","handlingStrategy":"retry","validationCode":"# choose max_wait based on expected job cost\nmax_wait = 600 if resolution in ('720P','768P') and duration == 6 else 1200\n# or compute from CLI: --max-wait","typeGuard":null,"tryCatchPattern":"try:\n    file_id = poll_task(task_id, max_wait=600)\nexcept SystemExit as e:\n    if 'Timeout' in str(e):\n        # resume later instead of re-submitting\n        file_id = resume_poll(task_id)\n    else:\n        raise","preventionTips":["Scale max_wait with resolution/duration (1080P + 10s needs the most time).","Persist task_id on disk so timed-out jobs can be resumed.","Avoid re-submitting on timeout — the original task may still finish."],"tags":["api","video-generation","timeout","retry"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}