{"record":{"id":"e7ceedcb0f6ae88e","repo":"googleapis/mcp-toolbox","slug":"health-info-should-not-empty-for-v","errorCode":null,"errorMessage":"health info should not empty for: %v","messagePattern":"health info should not empty for: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dgraph/dgraph.go","lineNumber":374,"sourceCode":"\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\n\tif len(result) == 0 {\n\t\treturn fmt.Errorf(\"health info should not empty for: %v\", url)\n\t}\n\n\tvar unhealthyErr error\n\tfor _, info := range result {\n\t\tif info.Status != \"healthy\" {\n\t\t\tunhealthyErr = fmt.Errorf(\"dgraph instance [%v] is not in healthy state, address is %v\",\n\t\t\t\tinfo.Instance, info.Address)\n\t\t} else {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn unhealthyErr\n}\n\nfunc getUrl(baseUrl, resource string, params url.Values) (string, error) {\n\tu, err := url.ParseRequestURI(baseUrl)\n\tif err != nil {","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dgraph/dgraph.go#L356-L392","documentation":"Thrown by the Dgraph source's healthCheck when the /health endpoint returns valid JSON but the array is empty, so there is no health information to evaluate. The library treats an empty health list as an invalid state for the given URL. Wrapped with %v.","triggerScenarios":"healthCheck successfully unmarshals the /health response but len(result) == 0, i.e. Dgraph (or an intermediary) returned an empty JSON array [] for that URL.","commonSituations":"A Dgraph instance that just started and reports no members yet, a Zero with no Alphas registered, or a proxy stripping/emptying the response body.","solutions":["Wait for Dgraph to finish startup and register its instances, then retry the health check.","Verify the /health endpoint directly: curl http://<host>:<port>/health and confirm a non-empty array is returned.","Point the source at the correct Dgraph instance (Zero vs Alpha) that actually reports health entries.","Restart the Dgraph cluster if it reports no members persistently."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"body, _ := fetchHealth(baseURL)\nvar entries []map[string]string\n_ = json.Unmarshal(body, &entries)\nif len(entries) == 0 {\n    return errors.New(\"dgraph /health returned an empty array; instance may still be starting\")\n}","typeGuard":null,"tryCatchPattern":"if err := healthCheck(ctx); err != nil {\n    if strings.Contains(err.Error(), \"health info should not empty\") {\n        // likely startup timing: wait and retry\n        time.Sleep(5 * time.Second)\n        return healthCheck(ctx)\n    }\n    return err\n}","preventionTips":["Add startup delays/readiness gates so the toolbox only initializes Dgraph sources after the cluster reports members.","Monitor the Dgraph cluster (Zero quorum, Alpha registration) independently of the toolbox.","Re-point the source at an instance known to report health entries."],"tags":["dgraph","health-check","empty-response"],"backgroundTag":"empty-health-response","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"}