{"record":{"id":"f69f2a4210a8a0f0","repo":"plandex-ai/plandex","slug":"error-reading-request-body","errorCode":null,"errorMessage":"Error reading request body: ","messagePattern":"Error reading request body: ","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/accounts.go","lineNumber":35,"sourceCode":"\t\"github.com/jmoiron/sqlx\"\n)\n\nfunc CreateAccountHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for CreateAccountHandler\")\n\n\tif os.Getenv(\"IS_CLOUD\") != \"\" {\n\t\tlog.Println(\"Creating accounts is not supported in cloud mode\")\n\t\thttp.Error(w, \"Creating accounts is not supported in cloud mode\", http.StatusNotImplemented)\n\t\treturn\n\t}\n\n\tisLocalMode := (os.Getenv(\"GOENV\") == \"development\" && os.Getenv(\"LOCAL_MODE\") == \"1\")\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: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvar req shared.CreateAccountRequest\n\terr = json.Unmarshal(body, &req)\n\tif err != nil {\n\t\tlog.Printf(\"Error unmarshalling request: %v\\n\", err)\n\t\thttp.Error(w, \"Error unmarshalling request: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\treq.Email = strings.ToLower(req.Email)\n\n\tvar emailVerificationId string\n\n\t// skipping email verification in dev/local mode\n\tif !isLocalMode {\n\t\temailVerificationId, err = db.ValidateEmailVerification(req.Email, req.Pin)\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/accounts.go#L17-L53","documentation":"CreateAccountHandler reads the raw request body with io.ReadAll; if that read fails (connection dropped mid-request, body stream error), it responds 500 with `Error reading request body: <detail>`. This happens before any JSON parsing, so the payload never reached unmarshalling.","triggerScenarios":"POSTing to the create-account endpoint with a broken/aborted connection, an oversized body that fails streaming, or a client that closes the connection before the body is fully transmitted.","commonSituations":"Flaky networks or proxies terminating long requests; HTTP clients with aggressive timeouts that abort while sending the body; load balancers with small body-size limits.","solutions":["Retry the request from the client once the connection is stable","Verify the HTTP client sends Content-Length / chunked encoding correctly and does not abort early","Check proxy/load-balancer body size and timeout limits","Inspect the server log line `Error reading request body: %v` for the underlying cause"],"exampleFix":"// before\nresp, err := http.Post(url, \"application/json\", brokenBodyReader)\n// after\nbody, _ := json.Marshal(req)\nresp, err := http.Post(url, \"application/json\", bytes.NewReader(body))","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp, err := http.Post(url, \"application/json\", bytes.NewReader(payload))\nif err != nil {\n    // transport-level failure: retry with backoff\n    resp, err = http.Post(url, \"application/json\", bytes.NewReader(payload))\n}","preventionTips":["Send the body from an in-memory reader, not a live stream that can abort","Set client timeouts longer than upload duration","Avoid proxies with small body limits for large payloads"],"tags":["http","request-body","io"],"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-12T22:17:10.623Z"}