{"record":{"id":"5f50d179e7c692d9","repo":"plandex-ai/plandex","slug":"error-reading-request-body-v","errorCode":null,"errorMessage":"error reading request body: %v","messagePattern":"error reading request body: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plans_exec.go","lineNumber":52,"sourceCode":"\n\tlog.Println(\"planId: \", planId)\n\n\tplan := authorizePlanExecUpdate(w, planId, auth)\n\tif plan == nil {\n\t\treturn\n\t}\n\n\tsettings, err := db.GetPlanSettings(plan)\n\tif err != nil {\n\t\tlog.Printf(\"Error getting plan settings: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting plan settings\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tbody, err := io.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.Printf(\"Error reading request body: %v\\n\", err)\n\t\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"error reading request body: %v\", err))\n\t\thttp.Error(w, \"Error reading request body\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\tdefer func() {\n\t\tlog.Println(\"Closing request body\")\n\t\tr.Body.Close()\n\t}()\n\n\tvar requestBody shared.TellPlanRequest\n\tif err := json.Unmarshal(body, &requestBody); err != nil {\n\t\tlog.Printf(\"Error parsing request body: %v\\n\", err)\n\t\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"error parsing request body: %v\", err))\n\t\thttp.Error(w, \"Error parsing request body\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t_, apiErr := hooks.ExecHook(hooks.WillTellPlan, hooks.HookParams{\n\t\tAuth: auth,","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_exec.go#L34-L70","documentation":"TellPlanHandler reads the entire HTTP request body with io.ReadAll(r.Body) before decoding it. If reading the stream fails (client disconnect, transport reset, body size issues), it logs, reports to notify, and returns HTTP 500 with 'Error reading request body'.","triggerScenarios":"The client's TCP connection drops or times out while the server is still reading the body; proxies/load balancers cut the request mid-body; request aborted via context cancellation.","commonSituations":"Slow uploads behind reverse proxies with aggressive idle timeouts; clients canceling requests; network instability between gateway and app.","solutions":["Retry the request from the client, ensuring the connection stays alive until the response arrives.","Check intermediary proxy/gateway timeout settings (e.g. proxy_read_timeout) and raise them.","Confirm the client sends Content-Length or valid chunked framing and doesn't abort early.","Inspect gateway access logs for 499/client-abort around the failure time."],"exampleFix":"// before\nbody, err := io.ReadAll(r.Body)\nif err != nil { http.Error(w, \"Error reading request body\", http.StatusInternalServerError) }\n// after\nbody, err := io.ReadAll(r.Body)\nif err != nil {\n    if errors.Is(err, context.Canceled) {\n        http.Error(w, \"request canceled\", http.StatusRequestTimeout)\n        return\n    }\n    http.Error(w, \"Error reading request body\", http.StatusInternalServerError)\n}","handlingStrategy":"validation","validationCode":"// Client side: send with proper framing and a context with adequate timeout\nctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\ndefer cancel()\nreq, _ := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(payload))\nreq.Header.Set(\"Content-Type\", \"application/json\")","typeGuard":null,"tryCatchPattern":"body, err := io.ReadAll(r.Body)\nif err != nil {\n    if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n        http.Error(w, \"request canceled\", http.StatusRequestTimeout)\n        return\n    }\n    http.Error(w, \"Error reading request body\", http.StatusInternalServerError)\n    return\n}","preventionTips":["Raise proxy/gateway read timeouts for large uploads.","Use Content-Length or correct chunked encoding from clients.","Retry idempotent requests on transient network failures.","Monitor 499/client-abort rates at the load balancer."],"tags":["http","network","go"],"backgroundTag":"request-body-read-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}