juicedata/juicefs · error
error GET request, status code %d
Error message
error GET request, status code %d
What it means
After the GET succeeds, getRequest rejects any response whose HTTP status is not exactly 200 and returns 'error GET request, status code %d'. This is an application-level rejection: the server answered, but not with the expected successful body — pprof endpoints and metric URLs return 200 for well-formed requests.
Source
Thrown at cmd/debug.go:234
if listenPort == -1 {
return 0, fmt.Errorf("no valid pprof port found")
}
return listenPort, nil
}
func getRequest(url string, timeout time.Duration) ([]byte, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
return nil, fmt.Errorf("error creating GET request: %v", err)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, fmt.Errorf("error GET request: %v", err)
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("error GET request, status code %d", resp.StatusCode)
}
defer func(body io.ReadCloser) {
if err := body.Close(); err != nil {
logger.Errorf("error closing body: %v", err)
}
}(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("error reading response: %v", err)
}
return body, nil
}
// check pprof service status
func checkPort(port int, amp string) error {
url := fmt.Sprintf("http://localhost:%d/debug/pprof/cmdline?debug=1", port)View on GitHub (pinned to c9a67b23e8)
Solutions
- Note the reported status code: 404 → wrong path/port; 403 → auth in front of the endpoint; 500 → check the JuiceFS client logs.
- Verify the port really belongs to the JuiceFS process: `lsof -i :<port> -nP | grep <pid>`; kill or skip foreign services on 6060-6099.
- Fetch the URL manually with `curl -i` to inspect headers/body and any proxy/auth challenge.
- Disable or bypass proxies/auth for localhost pprof endpoints (NO_PROXY=localhost,127.0.0.1).
- If a custom metric URL is used in reqAndSaveMetric, confirm it exists on the running JuiceFS version (URLs change between releases).
Example fix
// before
// getRequest rejects any non-200, so a 404 from a foreign service looks opaque
// after (caller-side check before probing)
if out, err := exec.Command("lsof", "-i", fmt.Sprintf(":%d", port), "-nP").CombinedOutput(); err != nil || !strings.Contains(string(out), "juicefs") {
return fmt.Errorf("port %d is not a juicefs listener", port)
} Defensive patterns
Strategy: validation
Validate before calling
resp, err := http.Head(u)
if err != nil { return err }
if resp.StatusCode != 200 {
return fmt.Errorf("endpoint %s answered %d; expected 200", u, resp.StatusCode)
} Try / catch
body, err := getRequest(url, timeout)
if err != nil {
var sc int
if _, serr := fmt.Sscanf(err.Error(), "error GET request, status code %d", &sc); serr == nil {
switch sc {
case 404: // wrong path/port — fix url or port discovery
case 403: // auth in front of endpoint — provide credentials/bypass proxy
default: // inspect endpoint health
}
return err
}
return err
} Prevention
- Check `curl -i` headers on the endpoint to see proxy/auth challenges before debugging.
- Ensure only the JuiceFS process occupies 6060-6099 so probes don't hit foreign 404s.
- Keep metric URLs in sync with the running JuiceFS version (paths change between releases).
- Set NO_PROXY=localhost,127.0.0.1 so proxies don't inject 403/407 responses on pprof probes.
When it happens
Trigger: Called from checkPort (cmdline probe) or reqAndSaveMetric when the target returns 404 (wrong pprof path or metric URL), 403 (auth/protection enabled on the endpoint, e.g. behind a proxy requiring credentials), 503/500 (endpoint crashed or overloaded), or a redirect-to-login (30x would actually be followed by DefaultClient and land on a non-200 page).
Common situations: A non-JuiceFS service occupies the discovered port (checkPort probes it blind and gets 404); pprof endpoint wrapped in an authenticated reverse proxy; metric URL typos after version changes; the mount process wedged so its pprof handler returns 500.
Related errors
- error creating GET request: %v
- error GET request: %v
- pprof will be collected, but no listen port
- failed to parse listen port: %v
- no valid pprof port found
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/d472b602b2c242c2.
Report an issue: GitHub.