plandex-ai/plandex · error

Error reading request body

Error message

Error reading request body

What it means

CreateProjectHandler reads the raw request body with io.ReadAll before decoding the CreateProjectRequest. A read error produces a 500 with 'Error reading request body'. Like error 1036, this is a transport/stream failure, not a payload-format problem.

Source

Thrown at app/server/handlers/projects.go:29

	shared "plandex-shared"

	"github.com/gorilla/mux"
	"github.com/jmoiron/sqlx"
)

func CreateProjectHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for CreateProjectHandler")

	auth := Authenticate(w, r, true)
	if auth == 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.CreateProjectRequest
	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
	}

	if requestBody.Name == "" {
		log.Println("Received empty name field")
		http.Error(w, "name field is required", http.StatusBadRequest)
		return
	}

	var projectId string

View on GitHub (pinned to e2d772072e)

Solutions

  1. Retry the create-project request once the network is stable.
  2. Raise proxy/LB timeouts and body size limits.
  3. Ensure the HTTP client completes the body write (check for early aborts, context cancellations).
  4. Inspect the server log's wrapped io error to pinpoint disconnect vs. infrastructure failure.

Example fix

// before
fetch(url, {method:'POST', body: JSON.stringify(project), signal: AbortSignal.timeout(500)}) // aborted mid-send
// after
fetch(url, {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(project), signal: AbortSignal.timeout(15000)})
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight: serialize and size-check the create-project payload
payload, err := json.Marshal(shared.CreateProjectRequest{Name: name})
if err != nil || len(payload) == 0 { return errors.New("empty or invalid create-project payload") }

Type guard

func bodyReadSucceeded(err error) bool { return err == nil }

Try / catch

err := withRetry(3, func() error {
    resp, e := postCreateProject(payload)
    if e != nil { return e }
    if resp.StatusCode == 500 && bodyContains(resp, "Error reading request body") {
        return errRetryable // connection dropped; retry with backoff
    }
    return nil
})

Prevention

When it happens

Trigger: io.ReadAll(r.Body) errors at projects.go:29 — client disconnected mid-request, proxy interrupted the upload, or the connection was reset before the body completed.

Common situations: Mobile/unstable clients dropping connections, gateway request timeouts, load balancers cutting long requests, or clients sending no body then closing abruptly.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/6dacbf8e01c99207. Report an issue: GitHub.