{"record":{"id":"4d270fef66468bb0","repo":"Kuberwastaken/claurst","slug":"transcription-api-returned","errorCode":null,"errorMessage":"Transcription API returned {}: {}","messagePattern":"Transcription API returned (.+?): (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-rust/crates/core/src/voice.rs","lineNumber":534,"sourceCode":"    let mut form = reqwest::multipart::Form::new()\r\n        .text(\"model\", model.to_string())\r\n        .part(\"file\", file_part);\r\n\r\n    if let Some(lang) = language {\r\n        form = form.text(\"language\", lang.to_string());\r\n    }\r\n\r\n    let response = client\r\n        .post(url)\r\n        .bearer_auth(api_key)\r\n        .multipart(form)\r\n        .send()\r\n        .await?;\r\n\r\n    let status = response.status();\r\n    if !status.is_success() {\r\n        let body = response.text().await.unwrap_or_default();\r\n        return Err(anyhow::anyhow!(\r\n            \"Transcription API returned {}: {}\",\r\n            status,\r\n            body\r\n        ));\r\n    }\r\n\r\n    let json: serde_json::Value = response.json().await?;\r\n    let text = json[\"text\"]\r\n        .as_str()\r\n        .unwrap_or(\"\")\r\n        .trim()\r\n        .to_string();\r\n    Ok(text)\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Global singleton\r\n// ---------------------------------------------------------------------------\r","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/core/src/voice.rs#L516-L552","documentation":"transcribe_audio sends the recorded audio to the configured Whisper-compatible endpoint and, on any non-success HTTP status, includes the status code and response body in the error. This surfaces upstream API failures (auth, rate limits, malformed requests, server errors) verbatim so the caller can diagnose them.","triggerScenarios":"POSTing audio to the transcription endpoint and receiving 4xx/5xx: invalid API key (401), quota exhausted (429), too-large payload (413), wrong endpoint URL (404), or transcription service outage (500/502).","commonSituations":"Expired/revoked OPENAI_API_KEY; local Whisper server not speaking the expected route; audio file exceeding provider size limit; rate limiting after heavy voice usage; typo'd WHISPER_ENDPOINT_URL.","solutions":["Read the status and body in the error to identify the cause (401 → fix key, 429 → back off, 404 → fix endpoint URL).","Verify OPENAI_API_KEY validity and quota.","Confirm WHISPER_ENDPOINT_URL points at the correct route (e.g. /inference for whisper.cpp).","Add retry with backoff for 5xx/429 statuses."],"exampleFix":"// before\nlet text = voice.record_and_transcribe().await?;\n// after\nmatch voice.record_and_transcribe().await {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"429\") => {\n        tokio::time::sleep(Duration::from_secs(5)).await;\n        voice.record_and_transcribe().await?\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"retry","validationCode":"let url = std::env::var(\"WHISPER_ENDPOINT_URL\")\n    .unwrap_or_else(|_| \"https://api.openai.com/v1/audio/transcriptions\".into());\n// sanity-check reachability before recording\nreqwest::get(url).await?.error_for_status()?;","typeGuard":null,"tryCatchPattern":"match voice.record_and_transcribe().await {\n    Err(e) if e.to_string().contains(\"returned 429\") => {\n        backoff_retry().await\n    }\n    Err(e) if e.to_string().contains(\"returned 401\") => {\n        prompt_for_api_key()?; voice.record_and_transcribe().await?\n    }\n    other => other,\n}","preventionTips":["Validate API keys and endpoint URLs before long recordings.","Implement backoff for 429/5xx responses.","Check provider audio size limits before uploading."],"tags":["http","whisper","api","transcription"],"backgroundTag":"http-error-response","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}