{"record":{"id":"1cffadf5372cb25e","repo":"babysor/MockingBird","slug":"emotion-enhance-returned-no-data-resp-text","errorCode":null,"errorMessage":"/emotion-enhance returned no data: {resp.text}","messagePattern":"/emotion-enhance returned no data: (.+?)","errorType":"http","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"skills/speak/scripts/noiz_tts.py","lineNumber":49,"sourceCode":"    return base64.b64encode(key.encode(\"utf-8\")).decode(\"ascii\")\n\n\ndef call_emotion_enhance(\n    base_url: str, api_key: str, text: str, timeout: int\n) -> str:\n    resp = requests.post(\n        f\"{base_url.rstrip('/')}/emotion-enhance\",\n        headers={\"Authorization\": api_key, \"Content-Type\": \"application/json\"},\n        json={\"text\": text},\n        timeout=timeout,\n    )\n    if resp.status_code != 200:\n        raise RuntimeError(\n            f\"/emotion-enhance failed: status={resp.status_code}, body={resp.text}\"\n        )\n    enhanced = resp.json().get(\"data\", {}).get(\"emotion_enhance\")\n    if not enhanced:\n        raise RuntimeError(f\"/emotion-enhance returned no data: {resp.text}\")\n    return enhanced\n\n\ndef synthesize(\n    base_url: str,\n    api_key: str,\n    text: str,\n    voice_id: Optional[str],\n    reference_audio: Optional[Path],\n    output_format: str,\n    speed: float,\n    emo: Optional[str],\n    target_lang: Optional[str],\n    similarity_enh: bool,\n    save_voice: bool,\n    duration: Optional[float],\n    timeout: int,\n    out_path: Path,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/babysor/MockingBird/blob/28dc5e14f12d7c754612af2fde8e78a4b03f8616/skills/speak/scripts/noiz_tts.py#L31-L67","documentation":"Raised by call_emotion_enhance when /emotion-enhance returns HTTP 200 but the JSON payload lacks data.emotion_enhance or it is empty/falsy. This indicates a contract mismatch: the server responded successfully but with an unexpected schema or empty result.","triggerScenarios":"POST /emotion-enhance returns 200 with body missing the \"data\" key, missing \"emotion_enhance\" inside it, or an empty string — e.g. server version change, empty input text echoed back, or an HTML/error page that happens to parse as JSON.","commonSituations":"API version drift where the response schema changed, gateway returning an empty JSON envelope, or passing blank text after strip().","solutions":["Print/inspect resp.text to see the actual payload shape","Verify you are on the API version whose responses include data.emotion_enhance","Guard upstream: reject empty text before calling the endpoint","Fall back to the original text when enhancement is unavailable"],"exampleFix":"# before\nenhanced = resp.json().get(\"data\", {}).get(\"emotion_enhance\")\nif not enhanced:\n    raise RuntimeError(f\"/emotion-enhance returned no data: {resp.text}\")\n# after (graceful fallback)\nenhanced = resp.json().get(\"data\", {}).get(\"emotion_enhance\") or text","handlingStrategy":"fallback","validationCode":"assert text and text.strip(), 'text required before emotion enhance'","typeGuard":null,"tryCatchPattern":"try:\n    enhanced = call_emotion_enhance(...)\nexcept RuntimeError as e:\n    if 'returned no data' in str(e):\n        enhanced = text  # graceful fallback\n    else:\n        raise","preventionTips":["Never call with empty text","Treat enhancement as optional: fall back to raw text","Pin the API version you tested against"],"tags":["http","api","schema","noiz-tts"],"backgroundTag":"unexpected-api-response-schema","analyzedSha":"28dc5e14f12d7c754612af2fde8e78a4b03f8616","analyzedAt":"2026-08-27T02:26:53.589Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}