{"record":{"id":"7bad03b58628c86c","repo":"MiniMax-AI/skills","slug":"generation-incomplete-status-status-json-dum","errorCode":null,"errorMessage":"Generation incomplete (status={status}): {json.dumps(data, indent=2)}","messagePattern":"Generation incomplete \\(status=(.+?)\\): (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/frontend-dev/scripts/minimax_music.py","lineNumber":83,"sourceCode":"        f\"{API_BASE}/music_generation\",\n        headers={\n            \"Authorization\": f\"Bearer {API_KEY}\",\n            \"Content-Type\": \"application/json\",\n        },\n        json=payload,\n        timeout=timeout,\n    )\n    resp.raise_for_status()\n    data = resp.json()\n\n    # Check API-level error\n    base_resp = data.get(\"base_resp\", {})\n    if base_resp.get(\"status_code\", 0) != 0:\n        raise SystemExit(f\"API Error [{base_resp.get('status_code')}]: {base_resp.get('status_msg')}\")\n\n    status = data.get(\"data\", {}).get(\"status\")\n    if status != 2:\n        raise SystemExit(f\"Generation incomplete (status={status}): {json.dumps(data, indent=2)}\")\n\n    audio_data = data.get(\"data\", {}).get(\"audio\", \"\")\n    if not audio_data:\n        raise SystemExit(f\"No audio in response: {json.dumps(data, indent=2)}\")\n\n    extra = data.get(\"extra_info\", {})\n\n    if output_format == \"hex\":\n        audio_bytes = bytes.fromhex(audio_data)\n    else:\n        # URL mode — audio_data is a URL string\n        audio_bytes = None\n\n    return {\n        \"audio_bytes\": audio_bytes,\n        \"audio_url\": audio_data if output_format == \"url\" else None,\n        \"duration\": extra.get(\"music_duration\"),\n        \"sample_rate\": extra.get(\"music_sample_rate\"),","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/frontend-dev/scripts/minimax_music.py#L65-L101","documentation":"music_generation returned base_resp.status_code 0 (no API error) but data.data.status is not 2. The script treats status==2 as the only success value; any other status means the track did not finish successfully in this synchronous call, and the full JSON is dumped for diagnosis.","triggerScenarios":"The endpoint returns a non-2 status (e.g. 1 processing, or a non-success terminal value) under backend load, when the chosen model/params cause a deferred result, or when an account-specific behavior makes the nominally-synchronous endpoint return an intermediate state.","commonSituations":"Backend congestion returning a still-processing status; a model variant that sometimes queues; regional endpoint behaving differently; transient generation hiccup where the track ultimately would succeed on retry.","solutions":["Inspect the dumped JSON — confirm the numeric status and any accompanying message field to know if it is transient or terminal.","Retry the identical request once or twice with a short delay; a non-2 but non-failure status often clears.","If it persists, simplify the request (drop lyrics_optimizer, switch model to music-2.5, lower sample_rate) to isolate the trigger.","Check the MiniMax status page / dashboard for an ongoing incident if many requests return the same non-2 status."],"exampleFix":"// before: single shot, hard fail\nif status != 2:\n    raise SystemExit(f\"Generation incomplete (status={status})\")\n\n// after: bounded retry for transient non-2 status\nfor attempt in range(3):\n    data = post(payload)\n    status = data.get(\"data\", {}).get(\"status\")\n    if status == 2:\n        break\n    time.sleep(5 * (attempt + 1))\nelse:\n    raise RuntimeError(f\"Generation never reached status=2 (last={status})\")","handlingStrategy":"retry","validationCode":"import requests, time\n\ndef generate_music_until_done(payload, attempts=3, delay=5):\n    for i in range(attempts):\n        data = requests.post(f\"{API_BASE}/music_generation\", json=payload, timeout=600).json()\n        if data.get(\"base_resp\", {}).get(\"status_code\", 0) != 0:\n            raise RuntimeError(data[\"base_resp\"])\n        status = data.get(\"data\", {}).get(\"status\")\n        if status == 2:\n            return data\n        time.sleep(delay * (i + 1))\n    raise RuntimeError(f\"music never reached status=2 (last={status})\")","typeGuard":"def is_terminal_music_status(status) -> bool:\n    \"\"\"status==2 is success; treat other known terminal values as non-retryable.\"\"\"\n    return status == 2  # extend set as the API documents more terminal codes","tryCatchPattern":"import subprocess, sys, time\nfor attempt in range(3):\n    r = subprocess.run([sys.executable, \"minimax_music.py\", \"--prompt\", p, \"-o\", out], capture_output=True, text=True)\n    if r.returncode == 0:\n        break\n    if \"Generation incomplete\" in (r.stderr or r.stdout or \"\"):\n        time.sleep(5 * (attempt + 1)); continue\n    raise RuntimeError(r.stderr or r.stdout)\nelse:\n    raise RuntimeError(\"music generation incomplete after retries\")","preventionTips":["Wrap music generation in a bounded retry loop keyed on the non-2 status rather than failing once.","Log the full status each attempt so you can distinguish persistent-failure from transient delay.","Keep the request identical across retries; only the timing changes.","Simplify params on repeated failures (switch model, drop lyrics_optimizer) to isolate the cause."],"tags":["api","transient","retry","minimax","music"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}