Adds a renderTemplate helper method on Handlers that renders templates to a bytes.Buffer first, then writes to the ResponseWriter only on success. This prevents partial/corrupt HTML responses when template execution fails partway through.
Changes
Added renderTemplate helper in handlers.go
Applied buffered rendering to ALL template execution sites:
## Summary
Adds a `renderTemplate` helper method on `Handlers` that renders templates to a `bytes.Buffer` first, then writes to the `ResponseWriter` only on success. This prevents partial/corrupt HTML responses when template execution fails partway through.
## Changes
- Added `renderTemplate` helper in `handlers.go`
- Applied buffered rendering to ALL template execution sites:
- `setup.go`: HandleSetupGET, renderSetupError
- `auth.go`: HandleLoginGET, HandleLoginPOST error paths (3 occurrences)
- `dashboard.go`: HandleDashboard
- `app.go`: HandleAppNew, HandleAppCreate error paths, HandleAppDetail, HandleAppEdit, HandleAppUpdate error path, HandleAppDeployments
- Added tests verifying complete HTML output (no partial renders)
## Test Results
All tests pass. One pre-existing lint issue (testpackage in tail_validation_test.go) unrelated to this change.
Closes #42
sneak
was assigned by clawbot2026-02-16 07:04:39 +01:00
Add renderTemplate helper method on Handlers that renders templates to a
bytes.Buffer first, then writes to the ResponseWriter only on success.
This prevents partial/corrupt HTML when template execution fails partway
through.
Applied to all template rendering call sites in:
- setup.go (HandleSetupGET, renderSetupError)
- auth.go (HandleLoginGET, HandleLoginPOST error paths)
- dashboard.go (HandleDashboard)
- app.go (HandleAppNew, HandleAppCreate, HandleAppDetail, HandleAppEdit,
HandleAppUpdate, HandleAppDeployments)
ok git.eeqj.de/sneak/upaas/internal/handlers 1.612s coverage: 23.5%
ok git.eeqj.de/sneak/upaas/internal/middleware 1.781s coverage: 47.1%
ok git.eeqj.de/sneak/upaas/internal/models 1.554s coverage: 53.1%
ok git.eeqj.de/sneak/upaas/internal/service/app 1.691s coverage: 82.8%
ok git.eeqj.de/sneak/upaas/internal/service/auth 2.825s coverage: 62.7%
ok git.eeqj.de/sneak/upaas/internal/service/webhook 2.521s coverage: 93.3%
ok git.eeqj.de/sneak/upaas/internal/ssh 2.192s coverage: 78.6%
Lint: ✅ No new issues
One pre-existing issue (testpackage in tail_validation_test.go) — unrelated to this PR.
## CI Results
### Tests: ✅ All passing
```
ok git.eeqj.de/sneak/upaas/internal/handlers 1.612s coverage: 23.5%
ok git.eeqj.de/sneak/upaas/internal/middleware 1.781s coverage: 47.1%
ok git.eeqj.de/sneak/upaas/internal/models 1.554s coverage: 53.1%
ok git.eeqj.de/sneak/upaas/internal/service/app 1.691s coverage: 82.8%
ok git.eeqj.de/sneak/upaas/internal/service/auth 2.825s coverage: 62.7%
ok git.eeqj.de/sneak/upaas/internal/service/webhook 2.521s coverage: 93.3%
ok git.eeqj.de/sneak/upaas/internal/ssh 2.192s coverage: 78.6%
```
### Lint: ✅ No new issues
One pre-existing issue (testpackage in `tail_validation_test.go`) — unrelated to this PR.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Adds a
renderTemplatehelper method onHandlersthat renders templates to abytes.Bufferfirst, then writes to theResponseWriteronly on success. This prevents partial/corrupt HTML responses when template execution fails partway through.Changes
renderTemplatehelper inhandlers.gosetup.go: HandleSetupGET, renderSetupErrorauth.go: HandleLoginGET, HandleLoginPOST error paths (3 occurrences)dashboard.go: HandleDashboardapp.go: HandleAppNew, HandleAppCreate error paths, HandleAppDetail, HandleAppEdit, HandleAppUpdate error path, HandleAppDeploymentsTest Results
All tests pass. One pre-existing lint issue (testpackage in tail_validation_test.go) unrelated to this change.
Closes #42
CI Results
Tests: ✅ All passing
Lint: ✅ No new issues
One pre-existing issue (testpackage in
tail_validation_test.go) — unrelated to this PR.