fix(04-CR-01): add r.ParseForm() to TaskCreateHandler and TaskUpdateHandler

Both handlers were missing the mandatory ParseForm call before reading
PostFormValue. This caused gorilla/csrf (which reads the body for CSRF
token validation) to consume the body, leaving PostFormValue to return
empty strings. TaskReorderHandler was used as the correct reference.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Arthur Belleville 2026-05-15 10:17:49 +02:00
parent 142ca547ea
commit e97f4988bd
No known key found for this signature in database

View file

@ -129,6 +129,11 @@ func TaskCreateHandler(deps TasksDeps) http.HandlerFunc {
}
ctx := r.Context()
if err := r.ParseForm(); err != nil {
http.Error(w, "bad request", http.StatusBadRequest)
return
}
title := strings.TrimSpace(r.PostFormValue("title"))
statusStr := r.PostFormValue("status")
status := parseTaskStatus(statusStr)
@ -318,6 +323,11 @@ func TaskUpdateHandler(deps TasksDeps) http.HandlerFunc {
}
ctx := r.Context()
if err := r.ParseForm(); err != nil {
http.Error(w, "bad request", http.StatusBadRequest)
return
}
title := strings.TrimSpace(r.PostFormValue("title"))
description := r.PostFormValue("description")