{"record":{"id":"6ca9f63425664a6d","repo":"plandex-ai/plandex","slug":"error-parsing-request-body-v","errorCode":null,"errorMessage":"error parsing request body: %v","messagePattern":"error parsing request body: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"app/server/handlers/plans_exec.go","lineNumber":64,"sourceCode":"\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,\n\t\tPlan: plan,\n\t})\n\tif apiErr != nil {\n\t\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"error executing will tell plan hook: %v\", apiErr))\n\t\twriteApiError(w, *apiErr)\n\t\treturn\n\t}\n\n\torgUserConfig, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)\n\tif err != nil {\n\t\tlog.Printf(\"Error getting org user config: %v\\n\", err)\n\t\thttp.Error(w, \"Error getting org user config\", http.StatusInternalServerError)","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/plans_exec.go#L46-L82","documentation":"TellPlanHandler unmarshals the raw request body into shared.TellPlanRequest with json.Unmarshal. Malformed or non-conforming JSON produces this error, an error notification, and an HTTP 400 'Error parsing request body'.","triggerScenarios":"Client POSTs to /tell with syntactically invalid JSON, wrong Content-Type payload (e.g. form-encoded), missing required fields where json.Unmarshal fails on type mismatch (e.g. string where number expected), or truncated body.","commonSituations":"Outdated client SDK sending the old request shape; curl tests with unescaped quotes; API version mismatch between client and server; gateway rewriting the body.","solutions":["Validate the JSON payload against TellPlanRequest's field types and re-send.","Ensure the client sends Content-Type: application/json.","Check for client/server version drift in the TellPlanRequest schema.","Log the offending body (redacted) to pinpoint the malformed portion."],"exampleFix":"// before\n{\"plan_id\": 123}\n// after\n{\"plan_id\": \"123\"}","handlingStrategy":"validation","validationCode":"// Client side: validate JSON before sending\npayload, err := json.Marshal(shared.TellPlanRequest{PlanId: planId, Text: text})\nif err != nil {\n    return fmt.Errorf(\"invalid request: %w\", err)\n}\nvar probe map[string]any\nif err := json.Unmarshal(payload, &probe); err != nil {\n    return fmt.Errorf(\"payload not valid JSON: %w\", err)\n}","typeGuard":"func isValidJSON(b []byte) bool {\n    var v any\n    return json.Unmarshal(b, &v) == nil\n}","tryCatchPattern":"var requestBody shared.TellPlanRequest\nif err := json.Unmarshal(body, &requestBody); err != nil {\n    http.Error(w, \"Error parsing request body\", http.StatusBadRequest)\n    return\n}","preventionTips":["Generate request bodies with typed Marshal, not string concatenation.","Keep client SDK in sync with the TellPlanRequest schema.","Always send Content-Type: application/json.","Validate payloads against the schema in client tests."],"tags":["json","http","validation"],"backgroundTag":"json-parse-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"}