{"record":{"id":"302eedbc70f387da","repo":"MiniMax-AI/skills","slug":"no-audio-in-response-json-dumps-data-indent-2","errorCode":null,"errorMessage":"No audio in response: {json.dumps(data, indent=2)}","messagePattern":"No audio in response: (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/frontend-dev/scripts/minimax_music.py","lineNumber":87,"sourceCode":"        },\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\"),\n        \"channels\": extra.get(\"music_channel\"),\n        \"bitrate\": extra.get(\"bitrate\"),\n        \"size\": extra.get(\"music_size\"),\n    }","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/frontend-dev/scripts/minimax_music.py#L69-L105","documentation":"A defensive guard: the response passed the status==2 check but data.data.audio is empty or missing, so there is nothing to decode (hex) or download (url). The full response JSON is dumped so you can see what the API actually returned.","triggerScenarios":"An edge response where status reports success but the audio payload is absent — a rare backend/serialization issue, an output_format the endpoint filled differently, or a response shape that diverged from the assumed `data.audio` location.","commonSituations":"Backend hiccup returning a success-shaped but empty payload; using an output_format value the account/model doesn't fully populate; an API version that moved the audio field; intermittent partial responses under load.","solutions":["Retry the identical request once — empty-audio-on-success is almost always transient.","Re-read the dumped JSON to confirm where the audio actually lives (it may have moved to a sibling field).","Try the alternate output_format (url vs hex) to see if the other mode populates the field.","If reproducible, capture the full JSON and report it with the model/region, since status==2 + empty audio is not an expected contract."],"exampleFix":"// before: assumes audio is always present on success\naudio_data = data.get(\"data\", {}).get(\"audio\", \"\")\n\n// after: search common locations and retry once\naudio_data = (data.get(\"data\", {}).get(\"audio\")\n              or data.get(\"data\", {}).get(\"audio_url\")\n              or data.get(\"audio\", \"\"))\nif not audio_data:\n    data = retry_request()  # one retry\n    audio_data = data.get(\"data\", {}).get(\"audio\", \"\")","handlingStrategy":"retry","validationCode":"def extract_audio(data: dict, output_format: str):\n    \"\"\"Return audio string from any plausible location, or None.\"\"\"\n    for path in ((\"data\", \"audio\"), (\"data\", \"audio_url\"), (\"audio\",)):\n        v = data\n        for k in path:\n            v = v.get(k, {}) if isinstance(v, dict) else None\n        if v:\n            return v\n    return None","typeGuard":"def has_music_audio(data: dict) -> bool:\n    \"\"\"True when a success response actually carries an audio payload.\"\"\"\n    return bool(extract_audio(data, data.get(\"output_format\", \"hex\")))","tryCatchPattern":"for attempt in range(2):\n    data = call_music_api(payload)\n    if data.get(\"data\", {}).get(\"status\") == 2:\n        audio = extract_audio(data, output_format)\n        if audio:\n            return audio\n    time.sleep(3)\nraise RuntimeError(\"music success but no audio after retry\")","preventionTips":["Treat status==2 with empty audio as transient — retry once before surfacing.","Search alternate field locations (data.audio_url, audio) in case the schema diverged.","Capture and log the full response when audio is missing so schema drift is visible.","Consider switching output_format (url vs hex) if one mode reliably yields empty payloads."],"tags":["api","data-integrity","minimax","music"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}