renderTemplate streams to the ResponseWriter, so a mid-render template error ships a partial page #123
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?
Root cause behind a defect found in the review of #116, and worth fixing independently of it.
renderTemplateexecutes straight into thehttp.ResponseWriter. A template error part-way through therefore leaves earlier output already written and the response committed — the handler cannot then set a 500, because the header is long gone. The client gets a truncated page, typically with a 200.It also silently weakens tests: a handler test can assert against content from the top of a page that aborted half way down and never notice. That is exactly what happened in PR 116 — three assertions passed against the flushed prefix of a page that failed at
{{.Webhook.RetentionLabel}}.Standard fix: execute into a
bytes.Buffer, and only on success set the content type and copy the buffer to theResponseWriter. On error, nothing has been written, so a real 500 can still be served.Definition of done
Implementation requirements
next, PR based onnext, single commit, title ending(closes #N).make checkplus the Docker lint path with the cache defeated.