ipfs/kubo · warning
err.Error()
Error message
err.Error()
What it means
The mutex-fraction endpoint parses the request body with r.ParseForm before reading the 'fraction' parameter. If the request body is malformed for form parsing (bad Content-Type, truncated body, invalid encoding), it returns HTTP 400 with the raw parse error text in the body.
Source
Thrown at core/corehttp/mutex_profile.go:22
"net"
"net/http"
"runtime"
"strconv"
core "github.com/ipfs/kubo/core"
)
// MutexFractionOption allows to set runtime.SetMutexProfileFraction via HTTP
// using POST request with parameter 'fraction'.
func MutexFractionOption(path string) ServeOption {
return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "only POST allowed", http.StatusMethodNotAllowed)
return
}
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
asfr := r.Form.Get("fraction")
if len(asfr) == 0 {
http.Error(w, "parameter 'fraction' must be set", http.StatusBadRequest)
return
}
fr, err := strconv.Atoi(asfr)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
log.Infof("Setting MutexProfileFraction to %d", fr)
runtime.SetMutexProfileFraction(fr)
})
View on GitHub (pinned to 329838acdf)
Solutions
- Send the parameter as a proper form body: `curl -X POST -d 'fraction=5' <debug-path>` (curl sets application/x-www-form-urlencoded).
- Ensure the Content-Type is application/x-www-form-urlencoded or multipart/form-data when POSTing manually.
- URL-encode parameter values correctly; avoid raw special characters in the fraction field.
- Verify no proxy/middleware is truncating or rewriting the request body.
Example fix
// before: JSON body cannot be form-parsed
curl -X POST -H 'Content-Type: application/json' -d '{"fraction":5}' <debug-path> // 400
// after
curl -X POST -d 'fraction=5' <debug-path> Defensive patterns
Strategy: validation
Validate before calling
form := url.Values{"fraction": {"5"}}
req, _ := http.NewRequest(http.MethodPost, debugURL, strings.NewReader(form.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// body is guaranteed parseable by r.ParseForm Try / catch
resp, err := http.DefaultClient.Do(req)
if err == nil && resp.StatusCode == http.StatusBadRequest {
body, _ := io.ReadAll(resp.Body)
// body contains the ParseForm error; fix Content-Type/encoding and resend
return fmt.Errorf("form rejected: %s", body)
} Prevention
- Always POST as application/x-www-form-urlencoded (curl -d does this automatically).
- Never send JSON bodies to this endpoint; it uses r.ParseForm.
- URL-encode all parameter values; invalid percent encodings fail ParseForm.
- Check proxies/middleware that rewrite or truncate request bodies.
When it happens
Trigger: POSTing to the mutex-fraction debug path with a body that cannot be parsed as a form — e.g. sending JSON without application/x-www-form-urlencoded or multipart/form-data, a corrupted/chunked body, or invalid URL encoding in the query/body.
Common situations: Scripts sending `--data` with JSON to the endpoint; clients setting the wrong Content-Type header; URL-encoded values containing invalid percent sequences; proxies mangling the request body.
Related errors
- only POST allowed
- parameter 'fraction' must be set
- unexpected redirect
- GitHub API returned HTTP %d for %s
- download returned HTTP %d
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/d00e8530201583f3.
Report an issue: GitHub.