BigPizzaV3/CodexPlusPlus · error · anyhow::Error
Audio transcriptions 请求缺少 Content-Type
Error message
Audio transcriptions 请求缺少 Content-Type
What it means
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.
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
Example fix
// before
client.post(url).body(form) // no content-type
// after (let the multipart builder set it)
let form = reqwest::multipart::Form::new().part("file", part);
client.post(url).multipart(form) // Content-Type + boundary set automatically Defensive patterns
Strategy: validation
Validate before calling
let ct = headers.get(CONTENT_TYPE).and_then(|v| v.to_str().ok()).unwrap_or("");
if ct.trim().is_empty() {
return Err(anyhow!("Audio transcriptions 请求缺少 Content-Type"));
} Try / catch
match open_audio_transcriptions_proxy_request(ct, body).await {
Ok(resp) => resp,
Err(e) if e.to_string().contains("缺少 Content-Type") => respond_400("multipart/form-data Content-Type required"),
Err(e) => return Err(e),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/c15974f970628308.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/protocol_proxy.rs:880
status_code,
is_stream: false,
content_type,
wire_api: UpstreamWireApi::Responses,
response: upstream,
})
}
pub async fn open_audio_transcriptions_proxy_request(
body: &[u8],
content_type: &str,
original_user_agent: Option<&str>,
) -> anyhow::Result<UpstreamProxyResponse> {
let settings = SettingsStore::default().load().unwrap_or_default();
let relay = crate::relay_rotation::select_relay_for_probe(&settings)?;
validate_upstream(&relay)?;
let content_type = content_type.trim();
if content_type.is_empty() {
anyhow::bail!("Audio transcriptions 请求缺少 Content-Type");
}
let endpoint = audio_transcriptions_url(&relay.base_url);
let _ = crate::diagnostic_log::append_diagnostic_log(
"protocol_proxy.audio_transcriptions_request",
json!({
"relayId": relay.id,
"relayName": relay.name,
"endpoint": endpoint,
"wireApi": UpstreamWireApi::AudioTranscriptions,
"bodyBytes": body.len()
}),
);
let request = crate::http_client::proxied_client(&effective_user_agent(
&relay.user_agent,
original_user_agent,
))?
.post(endpoint)View on GitHub (pinned to b1ed92e5e4)