Form-error paths commit a 4xx before rendering, so a failed render there cannot report 500 #128
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while fixing #123, out of that issue's scope.
renderTemplatenow buffers, so a mid-render failure never ships a partial body and can serve a real 500. Five call sites defeat the status half of that, because they callw.WriteHeaderbeforerenderTemplate:internal/handlers/auth.gorenderLoginErrorinternal/handlers/source_management.go, four form-validation branches (missing name, bad retention on create, and the two matching branches on edit)On those paths the status is already committed when rendering starts, so a template failure yields the pre-set 400 with an
Internal server errorbody rather than a 500. The body is honest and carries no part of the aborted page; only the status is wrong.Severity is low: it only shows up when a form-error page's own template fails. The fix is to let the render path carry the intended status and write the header after a successful render, e.g. a
renderTemplateStatus(w, r, page, data, status)variant that the plain helper delegates to with 200.Definition of done
WriteHeaderbeforerenderTemplate.