BigPizzaV3/CodexPlusPlus · error
图片 edits 请求缺少 Content-Type
Error message
图片 edits 请求缺少 Content-Type
What it means
For image edits requests, open_image_proxy_request requires a Content-Type header because edits use multipart or specific media types that cannot be defaulted. Generations requests default to application/json, but an edits request with an empty/missing Content-Type bails. The throw happens before the upstream request is built.
Solutions
- Ensure the client sends a Content-Type header (e.g. multipart/form-data with boundary) on image edits requests
- If calling the internal API directly, pass the original request's content type to open_image_edits_proxy_request
- Use the generations endpoint instead when submitting pure JSON requests
Defensive patterns
Strategy: validation
Validate before calling
if endpoint_is_edits && content_type.trim().is_empty() { return Err("edits request requires Content-Type"); } Try / catch
match open_image_edits_proxy_request(...) {
Err(e) if e.to_string().contains("缺少 Content-Type") => eprintln!("请为 edits 请求设置 Content-Type(如 multipart/form-data): {e}"),
other => other?,
} Prevention
- Always forward the inbound Content-Type header to the proxy call
- Keep multipart boundaries intact through any intermediary
- Use the generations endpoint for pure JSON requests
When it happens
Trigger: Calling open_image_edits_proxy_request (via open_image_proxy_request) with content_type empty or whitespace after trimming.
Common situations: Client stripped the Content-Type header on the inbound edits request; a gateway/intermediary removed it; code constructing the edits proxy call forgot to pass the inbound content type.
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/04616a8e66c4c09e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/protocol_proxy.rs:1002
crate::relay_config::relay_profile_base_url(&relay)
} else {
relay.upstream_base_url.trim().to_string()
};
if is_local_protocol_proxy_base_url(&base_url) {
anyhow::bail!("图片上游 Base URL 不能指向本地协议代理");
}
if base_url.trim().is_empty() {
anyhow::bail!("图片上游 Base URL 不能为空");
}
if relay.api_key.trim().is_empty() && !relay.uses_no_auth() {
anyhow::bail!("图片上游 Key 不能为空");
}
let content_type = content_type.trim();
let content_type = if content_type.is_empty() {
match endpoint_kind {
ImageProxyEndpoint::Generations => "application/json",
ImageProxyEndpoint::Edits => {
anyhow::bail!("图片 edits 请求缺少 Content-Type");
}
}
} else {
content_type
};
let endpoint = endpoint_kind.url(&base_url);
let wire_api = endpoint_kind.wire_api();
let _ = crate::diagnostic_log::append_diagnostic_log(
"protocol_proxy.image_request",
json!({
"relayId": relay.id,
"relayName": relay.name,
"endpoint": endpoint,
"wireApi": wire_api,
"bodyBytes": body.len(),
"endpointKind": endpoint_kind.name()
}),
);View on GitHub (pinned to b1ed92e5e4)