{"record":{"id":"b08a46ab91ca91a4","repo":"plandex-ai/plandex","slug":"error-reading-request-body-b08a46","errorCode":null,"errorMessage":"Error reading request body","messagePattern":"Error reading request body","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/plans_context.go","lineNumber":176,"sourceCode":"\tif auth == nil {\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\tplanId := vars[\"planId\"]\n\tbranchName := vars[\"branch\"]\n\tlog.Println(\"planId: \", planId)\n\n\tplan := authorizePlan(w, planId, auth)\n\tif plan == nil {\n\t\treturn\n\t}\n\n\t// read the request body\n\tbody, err := io.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.Printf(\"Error reading request body: %v\\n\", err)\n\t\thttp.Error(w, \"Error reading request body\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\tdefer r.Body.Close()\n\n\tvar requestBody shared.LoadContextRequest\n\tif err := json.Unmarshal(body, &requestBody); err != nil {\n\t\tlog.Printf(\"Error parsing request body: %v\\n\", err)\n\t\thttp.Error(w, \"Error parsing request body\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tres, _ := loadContexts(loadContextsParams{\n\t\tw:          w,\n\t\tr:          r,\n\t\tauth:       auth,\n\t\tloadReq:    &requestBody,\n\t\tplan:       plan,\n\t\tbranchName: branchName,","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_context.go#L158-L194","documentation":"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.","triggerScenarios":"Thrown at app/server/handlers/plans_context.go:176 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request from the client","Check for disconnects or proxies truncating large bodies","Verify Content-Length matches the body size"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// client-side: send a complete, bounded body\npayload, _ := json.Marshal(req)\nhttpReq, _ := http.NewRequest(http.MethodPost, url, bytes.NewReader(payload))\nhttpReq.ContentLength = int64(len(payload))\nhttpReq.Header.Set(\"Content-Type\", \"application/json\")","typeGuard":null,"tryCatchPattern":"body, err := io.ReadAll(r.Body)\nif err != nil {\n\tif errors.Is(err, context.Canceled) || errors.Is(err, io.ErrUnexpectedEOF) {\n\t\thttp.Error(w, \"Error reading request body\", http.StatusBadRequest)\n\t\treturn\n\t}\n\thttp.Error(w, \"Error reading request body\", http.StatusInternalServerError)\n\treturn\n}","preventionTips":["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"],"tags":[],"backgroundTag":null,"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"}