trackslash
TRACK-49 P2

No NotFound or MethodNotAllowed handlers: unstyled 404 and empty 405 responses

0
All issues

Description

The router registers no chi NotFound or MethodNotAllowed handlers, so unmatched portal URLs fall through to Go's plain-text defaults.

grep -rn '\.NotFound(\|\.MethodNotAllowed(' internal/server/*.go returns only three http.NotFound calls inside handlers (dev_reload.go:27, ui_account_pages.go:19, ui_push_notifications.go:23) — zero chi router registrations. There is also no styled error template in internal/server/templates/.

Steps to reproduce

Request Observed Expected
GET /{owner}/projects/{key}/sprnit 404 page not found, text/plain, no shell or CSS rendered HTML 404 inside the app shell
GET /logout (only POST registered, ui_routes.go:25) 405 with a completely empty body 405 with a rendered page
GET /{owner}/projects/{key}/issues (only POST, ui_routes.go:192) 405, empty body 405 with a rendered page
GET /api/v1/bogus 404 page not found, text/plain JSON {"error":"not found"}

Implementation note

chi propagates a root NotFound handler down into sub-routers whose own handler is still nil (Mux.NotFound → updateSubRoutes). So setting only r.NotFound(s.uiNotFound) at internal/server/server.go:118 would also install the HTML 404 on the /api/v1 sub-router created at server.go:146, and JSON clients would start receiving HTML.

Set HTML responders on the root router and explicitly set JSON responders inside the r.Route("/api/v1", ...) closure.

Fix

Add a styled 404/405 template, register HTML NotFound/MethodNotAllowed on the root, register JSON equivalents on the /api/v1 sub-router, and test both subtrees.

Sub-issues

0

Linked issues

0

GitHub

0

No branches or pull requests linked.

Comments

0
No comments.