harry0703/MoneyPrinterTurbo · error · ElevenLabsMusicError

ElevenLabs returned an invalid subscription response

Error message

ElevenLabs returned an invalid subscription response

What it means

ElevenLabsMusicError raised inside test_connection() when response.json() raises ValueError — the 2xx subscription response body was not valid JSON (truncated body, HTML error page from a proxy, or a decode error). The original ValueError is chained via 'from exc' for debugging. The request uses stream=True, so a truncated read is plausible on flaky connections.

Source

Thrown at app/services/elevenlabs_music.py:136

            headers={"xi-api-key": api_key},
            timeout=(15, 30),
            stream=True,
        ) as response:
            if response.status_code == 401:
                raise ElevenLabsAuthenticationError(
                    "ElevenLabs API key was rejected (401): "
                    f"{_safe_response_error(response)}"
                )
            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; "

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Retry once — truncated responses on unstable connections are the most common cause.
  2. If it persists, inspect what the configured music_base_url actually returns (curl the /user/subscription URL) and fix or unset the proxy/base URL override.
  3. Check whether an intercepting proxy or captive portal is in play (does the body look like HTML?).
Defensive patterns

Strategy: retry

Try / catch

try:
    test_connection()
except ElevenLabsMusicError as e:
    if 'invalid subscription response' in str(e):
        time.sleep(2)
        return test_connection()  # truncated body — retry once
    raise

Prevention

When it happens

Trigger: The subscription endpoint returns 200 with HTML (captive portal / proxy error page), a truncated JSON body due to a dropped connection, or a custom music_base_url returning a non-JSON success page.

Common situations: Corporate proxies intercepting HTTPS; misconfigured base URLs; captive portals on hotel networks; flaky mobile connections where the body cuts off mid-stream.

Related errors


AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14). Data as JSON: /api/errors/eb9b10d4a2db6075. Report an issue: GitHub.