{"record":{"id":"986e944a662506f7","repo":"googleapis/mcp-toolbox","slug":"error-performing-request-w","errorCode":null,"errorMessage":"error performing request: %w","messagePattern":"error performing request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dgraph/dgraph.go","lineNumber":354,"sourceCode":"\n\thc.AccessJwt = r.Data.AccessJWT\n\thc.RefreshToken = r.Data.RefreshJWT\n\treturn nil\n}\n\nfunc (hc *DgraphClient) healthCheck() error {\n\turl, err := getUrl(hc.baseUrl, \"/health\", nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating request: %w\", err)\n\t}\n\n\tresp, err := hc.httpClient.Do(req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error performing request: %w\", err)\n\t}\n\n\tdefer resp.Body.Close()\n\tdata, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar result []struct {\n\t\tInstance string `json:\"instance\"`\n\t\tAddress  string `json:\"address\"`\n\t\tStatus   string `json:\"status\"`\n\t}\n\n\t// Unmarshal response into the struct\n\tif err := json.Unmarshal(data, &result); err != nil {\n\t\treturn fmt.Errorf(\"failed to unmarshal json: %v\", err)\n\t}\n","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dgraph/dgraph.go#L336-L372","documentation":"Thrown by the Dgraph source's healthCheck when hc.httpClient.Do(req) fails, meaning the HTTP GET to the Dgraph /health endpoint could not be completed. The underlying transport error (DNS, dial, timeout, TLS) is wrapped with %w. This signals a network-level failure reaching the Dgraph Zero/Alpha, not an HTTP error status.","triggerScenarios":"healthCheck calls hc.httpClient.Do(req) against baseUrl + \"/health\" and the request fails before a response is returned: connection refused, DNS resolution failure, TLS handshake error, or context deadline exceeded.","commonSituations":"Dgraph container not running or crashed, wrong host/port in baseUrl, service in a different Docker network/namespace, firewall or network policy blocking the port, or the health check timing out under load.","solutions":["Verify Dgraph is running and reachable: curl http://<host>:<port>/health from the toolbox host/container.","Correct the baseUrl host/port in the Dgraph source configuration.","If containers are involved, confirm both are on the same Docker/Kubernetes network.","If intermittent, retry; persistent failures indicate connectivity or service-down issues."],"exampleFix":"// before\nbaseUrl: http://localhost:8080  // dgraph runs in another container\n// after\nbaseUrl: http://dgraph:8080  // use the service name on the shared network","handlingStrategy":"retry","validationCode":"// reachability probe before initializing the source\nresp, err := http.Get(\"http://dgraph:8080/health\")\nif err != nil {\n    return fmt.Errorf(\"dgraph unreachable at :8080: %w\", err)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if err := healthCheck(ctx); err != nil {\n    if strings.Contains(err.Error(), \"error performing request\") {\n        // transient network failure: retry with backoff\n        return retryWithBackoff(3, 2*time.Second, healthCheck)\n    }\n    return err\n}","preventionTips":["Verify network reachability (curl /health) from the toolbox host before wiring the source.","Place toolbox and Dgraph on the same Docker network / Kubernetes namespace.","Set reasonable HTTP client timeouts and monitor Dgraph container health.","Use service DNS names (e.g. http://dgraph:8080) rather than localhost in containerized setups."],"tags":["dgraph","network","http","health-check"],"backgroundTag":"connection-refused","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}