{"record":{"id":"69bfd8ace4635acc","repo":"dgraph-io/dgraph","slug":"server-response-s-s","errorCode":null,"errorMessage":"server response: %s - %s","messagePattern":"server response: (.+?) - (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/debuginfo/debugging.go","lineNumber":107,"sourceCode":"\t\treturn nil, fmt.Errorf(\"http fetch: %v\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\tdefer func() {\n\t\t\tif err := resp.Body.Close(); err != nil {\n\t\t\t\tglog.Warningf(\"error closing body: %v\", err)\n\t\t\t}\n\t\t}()\n\t\treturn nil, statusCodeError(resp)\n\t}\n\n\treturn resp.Body, nil\n}\n\nfunc statusCodeError(resp *http.Response) error {\n\tif resp.Header.Get(\"X-Go-Pprof\") != \"\" &&\n\t\tstrings.Contains(resp.Header.Get(\"Content-Type\"), \"text/plain\") {\n\t\tif body, err := io.ReadAll(resp.Body); err == nil {\n\t\t\treturn fmt.Errorf(\"server response: %s - %s\", resp.Status, body)\n\t\t}\n\t}\n\treturn fmt.Errorf(\"server response: %s\", resp.Status)\n}\n","sourceCodeStart":89,"sourceCodeEnd":112,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/debuginfo/debugging.go#L89-L112","documentation":"statusCodeError wraps a non-200 HTTP response from a debug/profile endpoint. When the server responds with a Go pprof marker header (X-Go-Pprof) and a text/plain body, the body is read and appended because it contains the actual pprof error message (e.g. profile unavailable). Otherwise only the HTTP status line is reported.","triggerScenarios":"dgraph debuginfo (or any fetchURL caller) hits /debug/pprof/* or /debug/vars style endpoints and the Alpha/Zero returns a non-200 status; fetchURL passes the response to statusCodeError.","commonSituations":"Profiling disabled or unavailable on the target node, requesting a profile that the runtime cannot produce (e.g. profile already active, CPU profiling in progress), wrong port (query HTTP port vs internal port), older/newer Dgraph version exposing different endpoints.","solutions":["Check the endpoint URL and port: the debuginfo --alpha/--zero flags must point to the correct HTTP (8080/6080) port.","Read the appended body in the error message — for pprof responses it states the server-side reason; fix accordingly (e.g. wait for an active profile to finish).","Verify the Alpha/Zero is healthy and supports the requested profile endpoint (curl http://<addr>/debug/pprof/).","Align Dgraph versions so all requested profiles/metrics exist on the server."],"exampleFix":"// before\ncmd := exec.Command(\"dgraph\", \"debuginfo\", \"--alpha\", \"localhost:9080\") // wrong port (gRPC)\n// after\ncmd := exec.Command(\"dgraph\", \"debuginfo\", \"--alpha\", \"localhost:8080\") // HTTP port","handlingStrategy":"try-catch","validationCode":"resp, err := http.Get(url)\nif err != nil { return err }\nif resp.StatusCode != http.StatusOK {\n    body, _ := io.ReadAll(resp.Body)\n    return fmt.Errorf(\"profile endpoint %s -> %d: %s\", url, resp.StatusCode, body)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if err := dgraphDebugInfoRun(...); err != nil {\n    var statusErr interface{ Error() string }\n    if strings.HasPrefix(err.Error(), \"server response: \") {\n        // parse status and appended pprof body; log endpoint + status\n        glog.Errorf(\"debuginfo fetch failed: %v\", err)\n    }\n    return err\n}","preventionTips":["Point --alpha/--zero at the correct HTTP port (8080/6080), not gRPC.","Curl the pprof endpoints before running debuginfo to confirm availability.","Avoid running debuginfo while another profile is active on the node.","Keep Dgraph tool and server versions aligned."],"tags":["http","network","pprof","debuginfo"],"backgroundTag":"http-non-200-response","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}