jdx/mise · error
unexpected request body
Error message
unexpected request body
What it means
In `forward`, every proxied request body is read (up to 8 MiB) and, unless the method is POST, the body must be empty. The relay only expects a body for the git smart-HTTP `git-upload-pack` POST; any GET/HEAD request carrying a body, or a non-POST method with payload bytes, is rejected as a protocol violation before anything is sent upstream.
Solutions
- Remove the body from the request; read-only relayed operations must be bodiless GET/HEAD requests
- Configure your HTTP client to not send a body (and no Content-Length/Transfer-Encoding) for GET/HEAD
- Only `POST git/OWNER/REPO/git-upload-pack` may carry a body — route writes elsewhere
- Check middleware/proxies for code that injects bodies into outgoing requests
Example fix
// before
client.get(url).body("").send()?;
// after
client.get(url).send()?; Defensive patterns
Strategy: try-catch
Validate before calling
fn body_is_permitted(method: &Method, body: &[u8]) -> bool {
(method == Method::POST) || body.is_empty()
}
assert!(body_is_permitted(&Method::GET, b"")); Try / catch
let result = async {
let target = authorize(&scope, method, path, query)?;
forward(target, request).await
}.await;
if let Err(e) = result {
if e.to_string().contains("unexpected request body") {
eprintln!("drop the body: only POST git-upload-pack may carry one");
}
} Prevention
- Send GET/HEAD requests with no body and no Content-Length/Transfer-Encoding headers
- Configure your HTTP client to omit empty bodies on read requests
- Only the git-upload-pack POST should carry a payload
- Audit middleware for code that attaches bodies to outgoing requests
When it happens
Trigger: A client sends GET/HEAD with a body (some HTTP clients serialize params into a body); a chunked or buffered body survives on requests that should be bodiless; a client mistakenly POSTs metadata with a body on a path whose allowlisted method is GET.
Common situations: HTTP libraries that attach an empty-but-present body to GET requests; misconfigured clients sending JSON payloads with GET; middleware adding bodies (e.g. signing wrappers) to otherwise read-only requests.
Related errors
- expected a GitHub repository in OWNER/REPO form
- GitHub relay is not connected
- GitHub relay permits read-only repository operations only
- invalid GitHub relay timeout policy
- invalid relay path
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/3b1700475fd0f616.
Report an issue: GitHub.
Appendix: source
Thrown at src/github_relay.rs:616
.body(Body::from("GitHub relay request denied or unavailable"))
.expect("valid response"),
}
}
async fn forward(broker: Broker, request: Request) -> Result<Response> {
let deadline = tokio::time::Instant::now() + broker.audit.options.request_timeout;
let operation = broker.audit.operation(&broker.scope, &request);
let permit = broker.permits.clone().try_acquire_owned()?;
let target = authorize(
&broker.scope,
request.method().as_str(),
request.uri().path().strip_prefix('/').unwrap_or_default(),
request.uri().query(),
)?;
let (parts, body) = request.into_parts();
let body = to_bytes(body, 8 * 1024 * 1024).await?;
if parts.method != Method::POST && !body.is_empty() {
bail!("unexpected request body");
}
let upstream = target.url.clone();
#[cfg(test)]
let upstream = if let Some(base) = &broker.test_upstream {
let url = Url::parse(&upstream)?;
format!(
"{base}{}{}",
url.path(),
url.query().map(|q| format!("?{q}")).unwrap_or_default()
)
} else {
upstream
};
let mut req = broker.client.request(parts.method.clone(), upstream);
if target.git {
req = req.basic_auth("x-access-token", Some(broker.token.as_str()));
} else {
req = req.bearer_auth(broker.token.as_str());View on GitHub (pinned to 533346cc37)