From 4137710c6b689db337d7ebb433aa844198c60a91 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 15 Nov 2026 13:04:05 -0800 Subject: [PATCH] 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 --- seaweed-block/core/host/volume/chunk_control.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/host/volume/chunk_control.go b/seaweed-block/core/host/volume/chunk_control.go index 48595c4fb4..f1fdfa77af 100644 --- a/seaweed-block/core/host/volume/chunk_control.go +++ b/seaweed-block/core/host/volume/chunk_control.go @@ -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 }