Fix dashboard CSRFField crash (closes #146) #147

Merged
sneak merged 2 commits from fix/dashboard-csrf-field into main 2026-02-26 12:07:43 +01:00
Collaborator

The dashboard template uses .CSRFField inside a {{range .AppStats}} block. Inside the range, . refers to *handlers.AppStats, not the root template data map. Changed to $.CSRFField to reference the root context.

make check passes. docker build . succeeds.

The dashboard template uses `.CSRFField` inside a `{{range .AppStats}}` block. Inside the range, `.` refers to `*handlers.AppStats`, not the root template data map. Changed to `$.CSRFField` to reference the root context. `make check` passes. `docker build .` succeeds.
sneak was assigned by clawbot 2026-02-26 11:58:29 +01:00
clawbot added 2 commits 2026-02-26 11:58:29 +01:00
Author
Collaborator

Test Results

1. Failing test (test-only commit, before fix)

=== RUN   TestHandleDashboard/renders_dashboard_with_apps_without_CSRFField_error
template execution failed: "execute page template dashboard.html: template: dashboard.html:72:19: executing "content" at <.CSRFField>: can't evaluate field CSRFField in type *handlers.AppStats"
    handlers_test.go:423: expected: 200, actual: 500
    handlers_test.go:424: "Internal Server Error
" does not contain "csrf-test-app"
--- FAIL: TestHandleDashboard/renders_dashboard_with_apps_without_CSRFField_error
FAIL

2. Passing test (after fix)

=== RUN   TestHandleDashboard/renders_dashboard_with_apps_without_CSRFField_error
--- PASS: TestHandleDashboard/renders_dashboard_with_apps_without_CSRFField_error (0.01s)
PASS
ok  git.eeqj.de/sneak/upaas/internal/handlers  0.226s

3. make check — all passing

==> All checks passed!

4. docker build . — success

Successfully built 8a8c3a64e2a6
## Test Results ### 1. Failing test (test-only commit, before fix) ``` === RUN TestHandleDashboard/renders_dashboard_with_apps_without_CSRFField_error template execution failed: "execute page template dashboard.html: template: dashboard.html:72:19: executing "content" at <.CSRFField>: can't evaluate field CSRFField in type *handlers.AppStats" handlers_test.go:423: expected: 200, actual: 500 handlers_test.go:424: "Internal Server Error " does not contain "csrf-test-app" --- FAIL: TestHandleDashboard/renders_dashboard_with_apps_without_CSRFField_error FAIL ``` ### 2. Passing test (after fix) ``` === RUN TestHandleDashboard/renders_dashboard_with_apps_without_CSRFField_error --- PASS: TestHandleDashboard/renders_dashboard_with_apps_without_CSRFField_error (0.01s) PASS ok git.eeqj.de/sneak/upaas/internal/handlers 0.226s ``` ### 3. `make check` — all passing ``` ==> All checks passed! ``` ### 4. `docker build .` — success ``` Successfully built 8a8c3a64e2a6 ```
clawbot changed title from fix: add CSRFField to dashboard template data (closes #146) to Fix dashboard CSRFField crash (closes #146) 2026-02-26 11:58:57 +01:00
Author
Collaborator

Test FAILING before fix:

--- FAIL: TestHandleDashboard/renders_dashboard_with_apps_without_crashing_on_CSRFField (0.01s)
    handlers_test.go:422: 
        Error: Not equal: expected: 200, actual: 500
        Messages: dashboard should not 500 when apps exist (CSRFField must be accessible)
    handlers_test.go:423: 
        Error: "Internal Server Error\n" does not contain "csrf-test-app"
FAIL

Test PASSING after fix:

--- PASS: TestHandleDashboard/renders_dashboard_with_apps_without_crashing_on_CSRFField (0.01s)
PASS
ok  git.eeqj.de/sneak/upaas/internal/handlers 0.248s

Linting, formatting, and build all pass: make check exits 0, docker build . succeeds.

**Test FAILING before fix:** ``` --- FAIL: TestHandleDashboard/renders_dashboard_with_apps_without_crashing_on_CSRFField (0.01s) handlers_test.go:422: Error: Not equal: expected: 200, actual: 500 Messages: dashboard should not 500 when apps exist (CSRFField must be accessible) handlers_test.go:423: Error: "Internal Server Error\n" does not contain "csrf-test-app" FAIL ``` **Test PASSING after fix:** ``` --- PASS: TestHandleDashboard/renders_dashboard_with_apps_without_crashing_on_CSRFField (0.01s) PASS ok git.eeqj.de/sneak/upaas/internal/handlers 0.248s ``` **Linting, formatting, and build all pass:** `make check` exits 0, `docker build .` succeeds.
sneak merged commit 019ba7fe1f into main 2026-02-26 12:07:43 +01:00
sneak deleted branch fix/dashboard-csrf-field 2026-02-26 12:07:43 +01:00
Sign in to join this conversation.