{"record":{"id":"0d91863739c99092","repo":"googleapis/mcp-toolbox","slug":"error-creating-request-w","errorCode":null,"errorMessage":"error creating request: %w","messagePattern":"error creating request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dgraph/dgraph.go","lineNumber":349,"sourceCode":"\t\treturn fmt.Errorf(\"no access JWT found in the response\")\n\t}\n\tif r.Data.RefreshJWT == \"\" {\n\t\treturn fmt.Errorf(\"no refresh JWT found in the response\")\n\t}\n\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","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dgraph/dgraph.go#L331-L367","documentation":"Thrown by the Dgraph source's healthCheck when http.NewRequest fails to construct the GET /health request (typically an invalid URL produced by getUrl from the configured baseUrl). The underlying parse/construct error is wrapped with %w. It indicates the source's baseUrl configuration is malformed rather than that Dgraph is unreachable.","triggerScenarios":"healthCheck is invoked (periodically or on connection use) and http.NewRequest(http.MethodGet, url, nil) returns an error because the url string built from hc.baseUrl plus \"/health\" cannot be parsed as a valid HTTP request target.","commonSituations":"BaseUrl set to something like \"dgraph:8080\" without a scheme, containing spaces or control characters, or an empty/placeholder value left in the YAML config.","solutions":["Fix the baseUrl in the Dgraph source config to a full absolute URL including scheme, e.g. http://dgraph:8080.","Test the URL locally with curl to confirm it parses, e.g. curl http://dgraph:8080/health.","Check for stray whitespace or quotes around the value in the YAML/tool config file."],"exampleFix":"// before\nbaseUrl: dgraph:8080\n// after\nbaseUrl: http://dgraph:8080","handlingStrategy":"validation","validationCode":"u, err := url.ParseRequestURI(cfg.Address)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid dgraph baseUrl %q: must be an absolute URL like http://host:8080\", cfg.Address)\n}","typeGuard":null,"tryCatchPattern":"if err := healthCheck(ctx); err != nil {\n    if strings.Contains(err.Error(), \"error creating request\") {\n        // treat as configuration error: fail fast, do not retry\n        return fmt.Errorf(\"misconfigured dgraph baseUrl: %w\", err)\n    }\n    return err\n}","preventionTips":["Always store the Dgraph address as a full absolute URL including http:// scheme and HTTP port (8080), not the gRPC port (9080).","Validate the source config with a URL parse check before deploying.","Avoid hand-edited URLs with stray whitespace or quotes in YAML."],"tags":["dgraph","http","url","config"],"backgroundTag":"invalid-url-config","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"}