From 6f1d4af035e21805191fea32ca43ec984ca904c0 Mon Sep 17 00:00:00 2001 From: MorezMartin Date: Mon, 22 Jun 2026 20:21:29 +0200 Subject: [PATCH] fix(filer): propagate proxyChunkId query params to volume server (#10036) * fix(filer): propagate proxyChunkId query params to volume server When weed mount reads via filer proxy mode (-volumeServerAccess=filerProxy), the mount adds query params like readDeleted=true to chunk read requests. Two bugs prevented these from working: 1. filer_server_handlers.go extracted fileId from the raw RequestURI, which includes query params, corrupting the fileId (e.g. '6,abc&readDeleted=true'). Fix: use r.URL.Query().Get("proxyChunkId") for clean extraction. 2. filer_server_handlers_proxy.go didn't forward query params to the volume server. The urlStrings from LookupFileId already contain the fileId in the path, so just append the original query string. * filer: match chunk proxy by query param, not URI prefix order Order-dependent prefix slicing missed proxyChunkId when it wasn't the first query param. Gate on root path and read the parsed query value. * filer: drop internal proxyChunkId from proxied volume query Lookup URLs already carry the fileId in the path, so forwarding the raw query duplicated proxyChunkId onto the volume server. Strip it and only append the remaining caller params (e.g. readDeleted). --------- Co-authored-by: Chris Lu --- weed/server/filer_server_handlers.go | 4 ++-- weed/server/filer_server_handlers_proxy.go | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/weed/server/filer_server_handlers.go b/weed/server/filer_server_handlers.go index 2fa9dee37..3062c3f72 100644 --- a/weed/server/filer_server_handlers.go +++ b/weed/server/filer_server_handlers.go @@ -58,8 +58,8 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { // proxy to volume servers var fileId string - if strings.HasPrefix(r.RequestURI, "/?proxyChunkId=") { - fileId = r.RequestURI[len("/?proxyChunkId="):] + if r.URL.Path == "/" { + fileId = r.URL.Query().Get("proxyChunkId") } if fileId != "" { fs.proxyToVolumeServer(w, r, fileId) diff --git a/weed/server/filer_server_handlers_proxy.go b/weed/server/filer_server_handlers_proxy.go index cdbb95321..ae73c88b1 100644 --- a/weed/server/filer_server_handlers_proxy.go +++ b/weed/server/filer_server_handlers_proxy.go @@ -61,9 +61,19 @@ func (fs *FilerServer) proxyToVolumeServer(w http.ResponseWriter, r *http.Reques return } - proxyReq, err := http.NewRequest(r.Method, urlStrings[rand.IntN(len(urlStrings))], r.Body) + // urlStrings from LookupFileId already contain the fileId in the path + // (e.g. http://server:8080/6,08136bdce4). Forward the caller's query params + // (e.g. readDeleted=true from weed mount) but drop the internal proxyChunkId. + targetURL := urlStrings[rand.IntN(len(urlStrings))] + query := r.URL.Query() + query.Del("proxyChunkId") + if encoded := query.Encode(); encoded != "" { + targetURL += "?" + encoded + } + + proxyReq, err := http.NewRequest(r.Method, targetURL, r.Body) if err != nil { - glog.ErrorfCtx(ctx, "NewRequest %s: %v", urlStrings[0], err) + glog.ErrorfCtx(ctx, "NewRequest %s: %v", targetURL, err) w.WriteHeader(http.StatusInternalServerError) return }