{"record":{"id":"371a477daaba4f0e","repo":"harry0703/MoneyPrinterTurbo","slug":"minimax-get-voice-returned-invalid-json","errorCode":null,"errorMessage":"MiniMax get_voice returned invalid JSON","messagePattern":"MiniMax get_voice returned invalid JSON","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"app/services/voice.py","lineNumber":1419,"sourceCode":"    response = requests.post(\n        voice_endpoint,\n        json={\"voice_type\": voice_type},\n        headers={\n            \"Authorization\": f\"Bearer {effective_api_key}\",\n            \"Content-Type\": \"application/json\",\n        },\n        timeout=30,\n    )\n    if response.status_code != 200:\n        raise RuntimeError(\n            f\"MiniMax get_voice failed with status {response.status_code}: \"\n            f\"{response.text[:200]}\"\n        )\n\n    try:\n        body = response.json()\n    except ValueError as exc:\n        raise RuntimeError(\"MiniMax get_voice returned invalid JSON\") from exc\n\n    base_resp = body.get(\"base_resp\") or {}\n    if base_resp.get(\"status_code\") not in {0, \"0\"}:\n        status_message = str(base_resp.get(\"status_msg\") or \"unknown error\")\n        raise RuntimeError(f\"MiniMax get_voice failed: {status_message}\")\n\n    catalog = []\n    seen_voice_ids = set()\n    response_groups = (\n        (\"system\", \"system_voice\"),\n        (\"voice_cloning\", \"voice_cloning\"),\n        (\"voice_generation\", \"voice_generation\"),\n    )\n    for normalized_type, response_key in response_groups:\n        for item in body.get(response_key) or []:\n            voice_id = str(item.get(\"voice_id\") or \"\").strip()\n            if not voice_id or voice_id in seen_voice_ids:\n                continue","sourceCodeStart":1401,"sourceCodeEnd":1437,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/voice.py#L1401-L1437","documentation":"MiniMax returned HTTP 200 for get_voice, but response.json() raised ValueError, meaning the body is not valid JSON (HTML error page, empty body, or gateway text). The original parse exception is chained via 'from exc'.","triggerScenarios":"A proxy, captive portal, or CDN in front of the endpoint returning HTML with status 200; truncated response body from a network hiccup; wrong endpoint domain serving a landing page.","commonSituations":"Corporate proxy intercepting HTTPS; custom endpoint misconfigured to a web UI URL rather than the API; transient gateway corruption; DNS pointing to the wrong host.","solutions":["Inspect response.text (log it before parsing) to see whether it is HTML/proxy output.","Fix the configured MiniMax endpoint so it points at the real API host.","Bypass or configure the proxy for this host; retry once for truncated-body transients."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    voices = list_minimax_voices(voice_type=vt)\nexcept RuntimeError as exc:\n    if \"invalid JSON\" in str(exc):\n        # likely proxy/gateway artifact — retry once, then report endpoint config\n        ...\n    raise","preventionTips":["Point the endpoint at the API host, not a web UI.","Exclude the MiniMax host from intercepting proxies."],"tags":["minimax","json","http","proxy"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}