plandex-ai/plandex · error
Error reading request body
Error message
Error reading request body
What it means
HTTP 500 error returned by LoadContextHandler when io.ReadAll fails while reading the raw request body, before any JSON parsing of shared.LoadContextRequest occurs. It indicates a transport-level failure reading the stream from the client (connection reset, read timeout, or closed body), not malformed request content. The plan has already been authorized when this fires.
Source
Thrown at app/server/handlers/plans_context.go:176
if auth == nil {
return
}
vars := mux.Vars(r)
planId := vars["planId"]
branchName := vars["branch"]
log.Println("planId: ", planId)
plan := authorizePlan(w, planId, auth)
if plan == nil {
return
}
// read the request body
body, err := io.ReadAll(r.Body)
if err != nil {
log.Printf("Error reading request body: %v\n", err)
http.Error(w, "Error reading request body", http.StatusInternalServerError)
return
}
defer r.Body.Close()
var requestBody shared.LoadContextRequest
if err := json.Unmarshal(body, &requestBody); err != nil {
log.Printf("Error parsing request body: %v\n", err)
http.Error(w, "Error parsing request body", http.StatusBadRequest)
return
}
res, _ := loadContexts(loadContextsParams{
w: w,
r: r,
auth: auth,
loadReq: &requestBody,
plan: plan,
branchName: branchName,View on GitHub (pinned to e2d772072e)
Solutions
- Retry the request from the client
- Check for disconnects or proxies truncating large bodies
- Verify Content-Length matches the body size
Defensive patterns
Strategy: validation
Validate before calling
// client-side: send a complete, bounded body
payload, _ := json.Marshal(req)
httpReq, _ := http.NewRequest(http.MethodPost, url, bytes.NewReader(payload))
httpReq.ContentLength = int64(len(payload))
httpReq.Header.Set("Content-Type", "application/json") Try / catch
body, err := io.ReadAll(r.Body)
if err != nil {
if errors.Is(err, context.Canceled) || errors.Is(err, io.ErrUnexpectedEOF) {
http.Error(w, "Error reading request body", http.StatusBadRequest)
return
}
http.Error(w, "Error reading request body", http.StatusInternalServerError)
return
} Prevention
- Keep request bodies modest and check proxy body-size limits (e.g. nginx client_max_body_size)
- Ensure clients don't abort uploads mid-stream (raise timeouts)
- Don't consume r.Body in middleware before handlers read it
- Set Content-Length or proper chunked encoding on client requests
When it happens
Trigger: Thrown at app/server/handlers/plans_context.go:176 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/b08a46ab91ca91a4.
Report an issue: GitHub.