{"record":{"id":"add467740d450b74","repo":"Hmbown/CodeWhale","slug":"translate-anthropic-messages-response-did-not-con","errorCode":null,"errorMessage":"translate: Anthropic Messages response did not contain text content","messagePattern":"translate: Anthropic Messages response did not contain text content","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/client.rs","lineNumber":2371,"sourceCode":"        temperature: None,\n        top_p: None,\n    }\n}\n\nfn translation_text_from_response(response: &MessageResponse) -> Result<String> {\n    let translated = response\n        .content\n        .iter()\n        .filter_map(|block| match block {\n            ContentBlock::Text { text, .. } => Some(text.as_str()),\n            _ => None,\n        })\n        .collect::<Vec<_>>()\n        .join(\"\")\n        .trim()\n        .to_string();\n    if translated.is_empty() {\n        bail!(\"translate: Anthropic Messages response did not contain text content\");\n    }\n    Ok(translated)\n}\n\nfn xiaomi_mimo_base_url_uses_token_plan(base_url: &str) -> bool {\n    let normalized = base_url.trim().to_ascii_lowercase();\n    let without_scheme = normalized\n        .strip_prefix(\"https://\")\n        .or_else(|| normalized.strip_prefix(\"http://\"))\n        .unwrap_or(&normalized);\n    let host = without_scheme\n        .split(['/', '?', '#'])\n        .next()\n        .unwrap_or_default();\n    let host = host.split(':').next().unwrap_or(host);\n    host.starts_with(\"token-plan-\") && host.ends_with(\".xiaomimimo.com\")\n}\n","sourceCodeStart":2353,"sourceCodeEnd":2389,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client.rs#L2353-L2389","documentation":"When translating text through an Anthropic Messages-format endpoint, the client joins all text content blocks of the response and requires non-empty text. If the response contained no text content (or only whitespace after trimming), it bails rather than returning an empty translation.","triggerScenarios":"The Anthropic Messages response contains only non-text blocks (e.g. tool_use), or an empty/whitespace-only text array — typically caused by an unexpected model reply or a degraded/proxy endpoint.","commonSituations":"Hitting a proxy/gateway that returns a mangled Messages payload; a model that replies with tool calls instead of text; quota/refusal responses shaped as non-text blocks.","solutions":["Retry the translation request; transient model/refusal responses often succeed on retry.","Inspect the raw response (enable logging) to see what content blocks were returned; switch to a model that returns plain text for translation.","If a proxy is in front of the provider, verify it forwards the Messages response unmodified.","Check provider status/quota — degraded endpoints may return empty content."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match translate_result {\n    Err(e) if e.to_string().contains(\"did not contain text content\") => {\n        log::warn!(\"Anthropic returned no text blocks; retrying once\");\n        translate_result = translate(input).await;\n    }\n    r => r?,\n}","preventionTips":["Retry once on empty-content translation errors before surfacing to the user.","Prefer models known to emit plain text for translation tasks.","Log raw response blocks when this error occurs to spot proxies mangling payloads."],"tags":["anthropic","translation","api-response","empty"],"backgroundTag":"empty-response-body","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}