volume: answer an unknown /chunk/* path with a typed JSON 404

Every /chunk error is a typed JSON body (B9 codes plus the 2026-11-15
transport errors), except an unknown path, which fell through to
net/http's plain-text "404 page not found". A catch-all /chunk/ route
now answers 404 {"code":"not_found","retryable":false}. The known routes
are unchanged; with the endpoint disabled, /chunk is still not mounted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-15 13:04:05 -08:00
1 parent 1bc9251c0c
commit 4137710c6b
1 file changed
+8 -1
@@ -88,7 +88,8 @@ type chunkErrorBody struct {
// The codes the routes add to the catalog's (B9 §2.2 plus the 2026-11-15
// rulings: awaiting_assignment, reconciling, internal, lsn_behind, and the
// transport errors bad_request, method_not_allowed, forbidden).
// transport errors bad_request, method_not_allowed, forbidden; not_found
// for an unknown /chunk path).
const (
codeVolumeNotServed = "volume_not_served"
codeNotPrimary = "not_primary"
@@ -104,6 +105,7 @@ const (
codeBadRequest = "bad_request"
codeMethodNotAllowed = "method_not_allowed"
codeForbidden = "forbidden"
codeNotFound = "not_found"
)
const chunkBodyLimit = 64 << 10
@@ -132,6 +134,11 @@ func (s *StatusServer) chunkMux() http.Handler {
mux.HandleFunc("/chunk/snapshots", s.handleChunkSnapshots)
mux.HandleFunc("/chunk/snapshot/delete", s.handleChunkSnapshotDelete)
mux.HandleFunc("/chunk/detach", s.handleChunkDetach)
// Any other /chunk path: a typed JSON 404, like every other /chunk
// error, not net/http's plain-text page.
mux.HandleFunc("/chunk/", func(w http.ResponseWriter, r *http.Request) {
writeChunkErr(w, http.StatusNotFound, codeNotFound, false, "no /chunk route %q", r.URL.Path)
})
return mux
}