{"record":{"id":"774da2f8c312585b","repo":"harry0703/MoneyPrinterTurbo","slug":"elevenlabs-subscription-response-does-not-include","errorCode":null,"errorMessage":"ElevenLabs subscription response does not include an account tier","messagePattern":"ElevenLabs subscription response does not include an account tier","errorType":"exception","errorClass":"ElevenLabsMusicError","httpStatus":null,"severity":"error","filePath":"app/services/elevenlabs_music.py","lineNumber":149,"sourceCode":"                    f\"{_safe_response_error(response)}\"\n                )\n            try:\n                payload = response.json()\n            except ValueError as exc:\n                raise ElevenLabsMusicError(\n                    \"ElevenLabs returned an invalid subscription response\"\n                ) from exc\n    except requests.RequestException as exc:\n        raise ElevenLabsMusicError(\n            f\"failed to connect to ElevenLabs: {exc}\"\n        ) from exc\n    if not isinstance(payload, dict):\n        raise ElevenLabsMusicError(\n            \"ElevenLabs returned an unexpected subscription response\"\n        )\n    tier = str(payload.get(\"tier\") or \"\").strip().lower()\n    if not tier:\n        raise ElevenLabsMusicError(\n            \"ElevenLabs subscription response does not include an account tier\"\n        )\n    if tier == \"free\":\n        raise ElevenLabsPaidPlanRequiredError(\n            \"ElevenLabs Music API requires a paid plan; \"\n            \"the current account is on the free tier\"\n        )\n    logger.info(f\"ElevenLabs account and plan check succeeded: tier={tier}\")\n    return payload\n\n\ndef validate_generation_access() -> None:\n    \"\"\"\n    在昂贵的视频流水线开始前排除确定无法生成配乐的账号。\n\n    免费套餐和无效 Key 都是确定性错误，必须立即终止，避免先消耗 LLM、TTS\n    和素材服务额度。订阅接口也可能因 Music-only endpoint scope、IP 限制或\n    临时网络问题不可访问；这些结果不能证明 Music API 不可用，因此只记录警告，","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/elevenlabs_music.py#L131-L167","documentation":"ElevenLabsMusicError raised by test_connection() when the subscription dict parsed successfully but payload['tier'] is missing, empty, or whitespace-only after str().strip().lower(). The tier field is what distinguishes free accounts (rejected separately) from paid ones, so a response without it cannot be validated. This indicates an unexpected API shape — normally only seen with custom base URLs, mocks, or undocumented upstream changes.","triggerScenarios":"Subscription endpoint returns 200 with a valid JSON dict lacking 'tier' (e.g. an error-shaped object like {\"detail\": {...}} with 200 status, or a partial mock).","commonSituations":"Mock/stub servers returning minimal objects; gateways that wrap responses ({\"data\": {...}}); ElevenLabs changing field names after an API revision.","solutions":["curl the subscription endpoint with the real key and inspect the JSON — confirm 'tier' is present in the raw response.","Fix the mock/gateway to pass the upstream body through unchanged.","If the upstream schema genuinely changed, update the parsing in elevenlabs_music.py to match the new field."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    test_connection()\nexcept ElevenLabsMusicError as e:\n    if 'does not include an account tier' in str(e):\n        warn('Unexpected API shape; check music_base_url or upstream API changes')\n        raise","preventionTips":["Pin tests/mocks to the documented subscription schema including the tier field.","Verify gateway passthrough does not wrap bodies in an envelope."],"tags":["elevenlabs","response-schema","validation","api"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}