{"record":{"id":"05d4772d3f5363a5","repo":"MiniMax-AI/skills","slug":"no-task-id-in-response-json-dumps-data-indent-2-05d477","errorCode":null,"errorMessage":"No task_id in response: {json.dumps(data, indent=2)}","messagePattern":"No task_id in response: (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/gif-sticker-maker/scripts/minimax_video.py","lineNumber":110,"sourceCode":"        \"prompt_optimizer\": prompt_optimizer,\n    }\n\n    if first_frame_image:\n        payload[\"first_frame_image\"] = first_frame_image\n\n    resp = requests.post(\n        f\"{API_BASE}/video_generation\",\n        headers=_headers(),\n        json=payload,\n        timeout=30,\n    )\n    resp.raise_for_status()\n    data = resp.json()\n    _check_resp(data)\n\n    task_id = data.get(\"task_id\")\n    if not task_id:\n        raise SystemExit(f\"No task_id in response: {json.dumps(data, indent=2)}\")\n    return task_id\n\n\ndef poll_task(task_id: str, interval: int = 10, max_wait: int = 600) -> str:\n    \"\"\"Poll task status until Success. Returns file_id.\"\"\"\n    elapsed = 0\n    while elapsed < max_wait:\n        resp = requests.get(\n            f\"{API_BASE}/query/video_generation\",\n            headers=_headers(),\n            params={\"task_id\": task_id},\n            timeout=30,\n        )\n        resp.raise_for_status()\n        data = resp.json()\n        _check_resp(data)\n\n        status = data.get(\"status\", \"\")","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/gif-sticker-maker/scripts/minimax_video.py#L92-L128","documentation":"After create_task() gets HTTP 200 and base_resp OK, it expects a task_id in the JSON. If absent, the response shape is unexpected — an API revision change, a proxy/gateway wrapper, or an error returned without a base_resp block. The full JSON is dumped to aid diagnosis.","triggerScenarios":"POST video_generation returns 200 with valid base_resp but no task_id key — e.g. API_BASE points to the wrong version path, a proxy wraps/renames the response, or a new API revision changed the contract.","commonSituations":"API_BASE missing the /v1 suffix or pointing to the wrong region; corporate proxy rewrites the body; SDK called against a newer/older API version than the script targets.","solutions":["Inspect the dumped JSON keys — they reveal whether the endpoint/contract changed.","Confirm API_BASE ends in /v1 and points to the correct region for the key.","Retry once; transient gateway wrappers sometimes intercept individual calls."],"exampleFix":"# before\ntask_id = create_task(prompt=p, model=m)\n\n# after - guard the contract before trusting the value\ndata = resp.json()\ntask_id = data.get('task_id')\nif not task_id:\n    # log full body, fall back to alternate key if API changed\n    task_id = data.get('id') or data.get('task', {}).get('id')\n    if not task_id:\n        raise RuntimeError(f'unexpected response: {data}')","handlingStrategy":"try-catch","validationCode":"def has_task_id(resp_json: dict) -> bool:\n    return bool(resp_json.get('task_id'))\n# after the POST, before relying on it:\nif not has_task_id(data):\n    raise RuntimeError(f'no task_id: {data}')","typeGuard":"def is_task_response(d) -> bool:\n    return isinstance(d, dict) and isinstance(d.get('task_id'), str) and bool(d['task_id'])","tryCatchPattern":"try:\n    task_id = create_task(prompt=p, model=m)\nexcept SystemExit as e:\n    raise RuntimeError(f'create_task returned no task_id: {e}') from e","preventionTips":["Pin API_BASE to a specific /v1 endpoint matching the script's contract.","Log the full response body once when integrating, to lock the expected schema.","Watch for proxy/gateway body rewriting in corporate networks."],"tags":["api","video-generation","response-shape","minimax"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}