plandex-ai/plandex · error
Error decoding request:
Error message
Error decoding request:
What it means
RejectFileHandler failed to decode the request body into shared.RejectFileRequest via json.NewDecoder(r.Body).Decode. The server returns HTTP 400 with this message because the JSON payload is malformed or of the wrong shape.
Source
Thrown at app/server/handlers/plans_changes.go:324
if auth == nil {
return
}
vars := mux.Vars(r)
planId := vars["planId"]
branch := vars["branch"]
log.Println("planId: ", planId, "branch: ", branch)
if authorizePlan(w, planId, auth) == nil {
return
}
var req shared.RejectFileRequest
err := json.NewDecoder(r.Body).Decode(&req)
if err != nil {
log.Printf("Error decoding request: %v\n", err)
http.Error(w, "Error decoding request: "+err.Error(), http.StatusBadRequest)
return
}
ctx, cancel := context.WithCancel(r.Context())
err = db.ExecRepoOperation(db.ExecRepoOperationParams{
OrgId: auth.OrgId,
UserId: auth.User.Id,
PlanId: planId,
Branch: branch,
Scope: db.LockScopeWrite,
Ctx: ctx,
CancelFn: cancel,
ClearRepoOnErr: true,
}, func(repo *db.GitRepo) error {
err = db.RejectPlanFile(auth.OrgId, planId, req.FilePath, time.Now())
if err != nil {
return errView on GitHub (pinned to e2d772072e)
Solutions
- Inspect the err.Error() appended to the message — it pinpoints the JSON syntax offset or type mismatch
- Log/verify the raw request body the client sent before decoding
- Ensure the client sends Content-Type: application/json and a valid JSON object like {"filePath":"..."}
- Check that RejectFileRequest field names/tags match what the client sends
Example fix
// before
curl -X POST .../plans/123/branch/main/reject -d 'filePath=foo.go'
// after
curl -X POST .../plans/123/branch/main/reject -H 'Content-Type: application/json' -d '{"filePath":"foo.go"}' Defensive patterns
Strategy: validation
Validate before calling
const body = JSON.stringify({ filePath });
JSON.parse(body); // throws early if payload is malformed
const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body }); Type guard
function isValidRejectFileRequest(v) { return typeof v === 'object' && v !== null && typeof v.filePath === 'string' && v.filePath.length > 0; } Try / catch
try { const res = await rejectFile(planId, branch, filePath); } catch (e) { if (e.status === 400 && e.message.startsWith('Error decoding request')) { console.error('Invalid payload:', e.message); } else throw e; } Prevention
- Always send Content-Type: application/json
- Validate payload shape client-side before the call
- Log the exact body being sent when debugging 400s
- Keep client types in sync with shared.RejectFileRequest
When it happens
Trigger: POST to the reject-file endpoint with a non-JSON body, invalid JSON syntax (unquoted keys, trailing commas), wrong Content-Type body, an empty body, or a body whose fields don't match RejectFileRequest (e.g. filePath as a number instead of string).
Common situations: Client SDK sends form-encoded instead of JSON; curl command missing -d or using single quotes incorrectly on Windows; API version change renamed the field; a proxy strips the body on redirects.
Related errors
- Error decoding request: %v
- Error marshalling response
- Error marshalling response: %v
- Error unmarshalling request:
- Custom model providers are not supported on Plandex Cloud
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/c74145687bb4543a.
Report an issue: GitHub.