plandex-ai/plandex · error

Error reading request body

Error message

Error reading request body

What it means

ApplyPlanHandler could not read the raw request body via io.ReadAll(r.Body) and returns 500 'Error reading request body'. Unlike JSON parsing errors (which are 400), this means the byte stream itself failed — the connection broke or the body could not be delivered.

Source

Thrown at app/server/handlers/plans_changes.go:130

	}

	vars := mux.Vars(r)
	planId := vars["planId"]
	branch := vars["branch"]
	log.Println("planId: ", planId, "branch: ", branch)

	plan := authorizePlan(w, planId, auth)
	if plan == nil {
		return
	}

	var err error

	// 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.ApplyPlanRequest
	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
	}

	// Just in case this was sent immediately after a stream finished, wait a little before locking to allow for cleanup
	time.Sleep(100 * time.Millisecond)

	ctx, cancel := context.WithCancel(r.Context())

	var settings *shared.PlanSettings
	var currentPlanParams db.CurrentPlanStateParams

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check client-side network stability and retry the apply
  2. Raise the reverse proxy body size limit (e.g. nginx client_max_body_size) if bodies are large
  3. Increase client HTTP timeout so the body finishes streaming
  4. Confirm no intermediary (LB, service mesh) is resetting the connection

Example fix

null
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try {
  const res = await fetch(applyUrl, {body: raw, signal: AbortSignal.timeout(60000)});
  if (res.status === 500 && (await res.text()).includes('Error reading request body')) {
    // connection dropped mid-upload — retry with backoff
  }
} catch (e) { /* network error path */ }

Prevention

When it happens

Trigger: Client disconnects mid-upload; proxy/load balancer terminates the connection; request exceeds a body size limit and the server/transport resets the stream.

Common situations: Unstable network or VPN dropping large uploads; reverse proxy (nginx) closing the request due to client_max_body_size; client timeout set shorter than upload time.

Related errors


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