{"record":{"id":"c15974f970628308","repo":"BigPizzaV3/CodexPlusPlus","slug":"audio-transcriptions-content-type","errorCode":null,"errorMessage":"Audio transcriptions 请求缺少 Content-Type","messagePattern":"Audio transcriptions 请求缺少 Content-Type","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/protocol_proxy.rs","lineNumber":880,"sourceCode":"        status_code,\n        is_stream: false,\n        content_type,\n        wire_api: UpstreamWireApi::Responses,\n        response: upstream,\n    })\n}\n\npub async fn open_audio_transcriptions_proxy_request(\n    body: &[u8],\n    content_type: &str,\n    original_user_agent: Option<&str>,\n) -> anyhow::Result<UpstreamProxyResponse> {\n    let settings = SettingsStore::default().load().unwrap_or_default();\n    let relay = crate::relay_rotation::select_relay_for_probe(&settings)?;\n    validate_upstream(&relay)?;\n    let content_type = content_type.trim();\n    if content_type.is_empty() {\n        anyhow::bail!(\"Audio transcriptions 请求缺少 Content-Type\");\n    }\n\n    let endpoint = audio_transcriptions_url(&relay.base_url);\n    let _ = crate::diagnostic_log::append_diagnostic_log(\n        \"protocol_proxy.audio_transcriptions_request\",\n        json!({\n            \"relayId\": relay.id,\n            \"relayName\": relay.name,\n            \"endpoint\": endpoint,\n            \"wireApi\": UpstreamWireApi::AudioTranscriptions,\n            \"bodyBytes\": body.len()\n        }),\n    );\n    let request = crate::http_client::proxied_client(&effective_user_agent(\n        &relay.user_agent,\n        original_user_agent,\n    ))?\n    .post(endpoint)","sourceCodeStart":862,"sourceCodeEnd":898,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/protocol_proxy.rs#L862-L898","documentation":"open_audio_transcriptions_proxy_request forwards multipart audio transcription uploads to the selected upstream relay. A multipart request must carry a Content-Type (boundary-delimited), so an empty or whitespace-only content_type argument is rejected before building the upstream request.","triggerScenarios":"audio_transcriptions_proxy_forwards_multipart_body (or the no-auth probe path) is invoked with a content_type parameter that is empty or only whitespace after trim, hitting `content_type.is_empty()` and bailing.","commonSituations":"Client sent POST /audio/transcriptions without a Content-Type header; a test harness called the proxy function passing \"\" explicitly; an intermediary stripped the Content-Type header from the multipart request.","solutions":["Ensure the client sends the multipart upload with `Content-Type: multipart/form-data; boundary=...` (SDKs set this automatically when given a file, never set it manually without a boundary)","Check for middleware/proxies stripping or rewriting the Content-Type header and exempt multipart endpoints","In tests, pass the recorded request's actual content-type header instead of an empty string"],"exampleFix":"// before\nclient.post(url).body(form)  // no content-type\n// after (let the multipart builder set it)\nlet form = reqwest::multipart::Form::new().part(\"file\", part);\nclient.post(url).multipart(form) // Content-Type + boundary set automatically","handlingStrategy":"validation","validationCode":"let ct = headers.get(CONTENT_TYPE).and_then(|v| v.to_str().ok()).unwrap_or(\"\");\nif ct.trim().is_empty() {\n    return Err(anyhow!(\"Audio transcriptions 请求缺少 Content-Type\"));\n}","typeGuard":null,"tryCatchPattern":"match open_audio_transcriptions_proxy_request(ct, body).await {\n    Ok(resp) => resp,\n    Err(e) if e.to_string().contains(\"缺少 Content-Type\") => respond_400(\"multipart/form-data Content-Type required\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Always build multipart bodies with an HTTP client's multipart API so the boundary header is set automatically","Never hardcode Content-Type: multipart/form-data without a boundary","Return a clear 400 to clients omitting Content-Type instead of proxying"],"tags":["proxy","http","multipart","audio"],"backgroundTag":"missing-required-argument","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}