setupSPA in internal/server/routes.go reads request.URL.Path[1:] to find the file to serve. An absolute-form request line with no path, GET http://127.0.0.1:53273 HTTP/1.1, gives an empty URL.Path, so the slice panics with runtime error: slice bounds out of range [1:0]. chi's Recoverer turns it into a 500 with an empty body and prints a stack trace to the log for every such request; no authentication is needed. Seen on eceb5f2. GET / is fine.
Fix: strings.TrimPrefix(request.URL.Path, "/") and serve index.html for an empty result, as for any unknown path.
Definition of done
A request whose URL.Path is empty gets the index page with 200 and no panic in the log.
A test in internal/server built on httptest.NewRequest("GET", "http://example.com", nil), whose path is empty.
One reviewed PR against next.
Model: fable-5-1
`setupSPA` in `internal/server/routes.go` reads `request.URL.Path[1:]` to find the file to serve. An absolute-form request line with no path, `GET http://127.0.0.1:53273 HTTP/1.1`, gives an empty `URL.Path`, so the slice panics with `runtime error: slice bounds out of range [1:0]`. chi's `Recoverer` turns it into a `500` with an empty body and prints a stack trace to the log for every such request; no authentication is needed. Seen on `eceb5f2`. `GET /` is fine.
Fix: `strings.TrimPrefix(request.URL.Path, "/")` and serve `index.html` for an empty result, as for any unknown path.
## Definition of done
1. A request whose `URL.Path` is empty gets the index page with `200` and no panic in the log.
2. A test in `internal/server` built on `httptest.NewRequest("GET", "http://example.com", nil)`, whose path is empty.
3. One reviewed PR against `next`.
Model: fable-5-1
clawbot
self-assigned this 2026-10-20 17:04:06 +02:00
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.
setupSPAininternal/server/routes.goreadsrequest.URL.Path[1:]to find the file to serve. An absolute-form request line with no path,GET http://127.0.0.1:53273 HTTP/1.1, gives an emptyURL.Path, so the slice panics withruntime error: slice bounds out of range [1:0]. chi'sRecovererturns it into a500with an empty body and prints a stack trace to the log for every such request; no authentication is needed. Seen oneceb5f2.GET /is fine.Fix:
strings.TrimPrefix(request.URL.Path, "/")and serveindex.htmlfor an empty result, as for any unknown path.Definition of done
URL.Pathis empty gets the index page with200and no panic in the log.internal/serverbuilt onhttptest.NewRequest("GET", "http://example.com", nil), whose path is empty.next.Model: fable-5-1