harry0703/MoneyPrinterTurbo · error · ElevenLabsMusicError
ElevenLabs returned an unexpected subscription response
Error message
ElevenLabs returned an unexpected subscription response
What it means
ElevenLabsMusicError raised by test_connection() when the parsed subscription payload is JSON but not a dict — e.g. a bare string, list, or number. The ElevenLabs API returns a JSON object, so this indicates a non-ElevenLabs responder: a custom music_base_url, a mock server, or an intermediary returning scalar/array JSON. It is distinct from error 29 (body not JSON at all) and fires only after json() succeeded.
Source
Thrown at app/services/elevenlabs_music.py:144
)
if not response.ok:
raise ElevenLabsMusicError(
"ElevenLabs account check failed "
f"({response.status_code}): "
f"{_safe_response_error(response)}"
)
try:
payload = response.json()
except ValueError as exc:
raise ElevenLabsMusicError(
"ElevenLabs returned an invalid subscription response"
) from exc
except requests.RequestException as exc:
raise ElevenLabsMusicError(
f"failed to connect to ElevenLabs: {exc}"
) from exc
if not isinstance(payload, dict):
raise ElevenLabsMusicError(
"ElevenLabs returned an unexpected subscription response"
)
tier = str(payload.get("tier") or "").strip().lower()
if not tier:
raise ElevenLabsMusicError(
"ElevenLabs subscription response does not include an account tier"
)
if tier == "free":
raise ElevenLabsPaidPlanRequiredError(
"ElevenLabs Music API requires a paid plan; "
"the current account is on the free tier"
)
logger.info(f"ElevenLabs account and plan check succeeded: tier={tier}")
return payload
def validate_generation_access() -> None:
"""View on GitHub (pinned to 1f9f19c202)
Solutions
- Point music_base_url at the real API (or unset it to use the default) when doing real account checks.
- If using a mock, make it return a JSON object shaped like the subscription response ({"tier": "creator", ...}).
- If neither applies, dump the raw body once (curl) and compare against the documented subscription schema.
Example fix
# mock server fix
# before: b'[]'
# after
b'{"tier": "creator"}' Defensive patterns
Strategy: validation
Try / catch
try:
test_connection()
except ElevenLabsMusicError as e:
if 'unexpected subscription response' in str(e):
log('music_base_url may point at a non-ElevenLabs responder')
raise ConfigError('verify music_base_url configuration') from e Prevention
- Leave music_base_url unset unless a compatible gateway is verified end-to-end.
- Make mock servers return JSON objects matching the subscription schema.
- Re-check custom gateways after any API version bump.
When it happens
Trigger: config.elevenlabs.music_base_url points at a stub/mock returning '[]' or '"ok"' with status 200; a service-mesh sidecar answering the path with a JSON array; an API version change that altered the payload shape.
Common situations: Testing against a local mock server; custom enterprise gateways rewriting responses; upstream API contract changes after an ElevenLabs update.
Related errors
- ElevenLabs returned an invalid subscription response
- ElevenLabs subscription response does not include an account
- ElevenLabs API key is required
- ElevenLabs API key was rejected (401): {_safe_response_error
- ElevenLabs account check failed ({response.status_code}): {_
AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14).
Data as JSON: /api/errors/2c5c7f1baa6e9c6a.
Report an issue: GitHub.