harry0703/MoneyPrinterTurbo · error · RuntimeError
MiniMax get_voice returned invalid JSON
Error message
MiniMax get_voice returned invalid JSON
What it means
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'.
Source
Thrown at app/services/voice.py:1419
response = requests.post(
voice_endpoint,
json={"voice_type": voice_type},
headers={
"Authorization": f"Bearer {effective_api_key}",
"Content-Type": "application/json",
},
timeout=30,
)
if response.status_code != 200:
raise RuntimeError(
f"MiniMax get_voice failed with status {response.status_code}: "
f"{response.text[:200]}"
)
try:
body = response.json()
except ValueError as exc:
raise RuntimeError("MiniMax get_voice returned invalid JSON") from exc
base_resp = body.get("base_resp") or {}
if base_resp.get("status_code") not in {0, "0"}:
status_message = str(base_resp.get("status_msg") or "unknown error")
raise RuntimeError(f"MiniMax get_voice failed: {status_message}")
catalog = []
seen_voice_ids = set()
response_groups = (
("system", "system_voice"),
("voice_cloning", "voice_cloning"),
("voice_generation", "voice_generation"),
)
for normalized_type, response_key in response_groups:
for item in body.get(response_key) or []:
voice_id = str(item.get("voice_id") or "").strip()
if not voice_id or voice_id in seen_voice_ids:
continueView on GitHub (pinned to 1f9f19c202)
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.
Defensive patterns
Strategy: retry
Try / catch
try:
voices = list_minimax_voices(voice_type=vt)
except RuntimeError as exc:
if "invalid JSON" in str(exc):
# likely proxy/gateway artifact — retry once, then report endpoint config
...
raise Prevention
- Point the endpoint at the API host, not a web UI.
- Exclude the MiniMax host from intercepting proxies.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- ElevenLabs returned an invalid subscription response
- Sonilo returned an invalid service response
- MiniMax get_voice failed with status {response.status_code}:
- ElevenLabs returned an unexpected subscription response
- ElevenLabs video proxy is empty or exceeds the 200 MB limit
AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14).
Data as JSON: /api/errors/371a477daaba4f0e.
Report an issue: GitHub.