Artifact d524549e68375579646fa0ffa12c95e6a07b6fbce3ee43b07da728cc07d0ad3c:
- File
internal/web/repopath_test.go
— part of check-in
[059fe0bdde]
at
2026-08-25 21:49:04
on branch ops-drill
— ops: record which repository a render was for
Repo was read with req.PathValue in the outermost middleware, where the router has not set it — path values live on the request the mux passes DOWN, a copy that middleware never sees. Same shape as the route-pattern bug, and it went unnoticed longer because an empty string looks like 'no repository' rather than like a failure.
Every render recorded until now carried an empty repo: 61 of 61 rows in the analytics store, on a fleet where repository size is the dominant cost of almost everything. The drilldown's by-repository table showed a single '(none)' row, which is what surfaced it.
Read from the path instead, unescaping as the router would. (user: dmestas, size: 1058) [annotate] [blame] [check-ins using] [more...]
package web import "testing" // Repo was read with req.PathValue in the outermost middleware, where // the router has not set it: path values live on the request the mux // passes DOWN, a copy that middleware never sees. Every render recorded // before this carried an empty repo — 61 of 61 rows in the analytics // store — which made every number unattributable on a fleet where // repository size is the dominant cost. func TestRepoOfPath(t *testing.T) { for path, want := range map[string]string{ "/r/pikchr": "pikchr", "/r/pikchr/": "pikchr", "/r/fossil/timeline": "fossil", "/r/fossil/checkin/abc123": "fossil", "/r/spatialite%2Dtools/docs": "spatialite-tools", // the router would unescape it "/fleet": "", "/fleet/ops": "", "/": "", "": "", "/r/": "", } { if got := repoOfPath(path); got != want { t.Errorf("repoOfPath(%q) = %q, want %q", path, got, want) } } }