{"record":{"id":"53de6e88720416fb","repo":"googleapis/mcp-toolbox","slug":"failed-to-get-url-v","errorCode":null,"errorMessage":"failed to get url %v","messagePattern":"failed to get url (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dgraph/dgraph.go","lineNumber":393,"sourceCode":"\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 {\n\t\treturn \"\", fmt.Errorf(\"failed to get url %v\", err)\n\t}\n\tu.Path = resource\n\tu.RawQuery = params.Encode()\n\treturn u.String(), nil\n}\n\nfunc checkError(resp []byte) error {\n\tvar errResp struct {\n\t\tErrors []struct {\n\t\t\tMessage string `json:\"message\"`\n\t\t} `json:\"errors\"`\n\t}\n\n\tif err := json.Unmarshal(resp, &errResp); err != nil {\n\t\treturn fmt.Errorf(\"failed to unmarshal json: %v\", err)\n\t}\n\n\tif len(errResp.Errors) > 0 {","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dgraph/dgraph.go#L375-L411","documentation":"Thrown by getUrl in the Dgraph source when url.ParseRequestURI(baseUrl) fails, so a request URL cannot be built for any operation (postDqlQuery, mutate, doLogin, healthCheck all call it). It means the configured baseUrl is not a parseable absolute URI. The parse error is wrapped with %v.","triggerScenarios":"Any Dgraph operation calls getUrl(baseUrl, resource, params) and url.ParseRequestURI rejects the baseUrl because it lacks a scheme, contains spaces/control chars, or is otherwise malformed.","commonSituations":"Missing http:// scheme in the config (e.g. \"localhost:8080\" or \"dgraph:9080\" — the gRPC port), environment variable interpolation leaving the value empty, or copying a URL with surrounding quotes/spaces.","solutions":["Set the Dgraph source's baseUrl to a full absolute URL with scheme, e.g. http://dgraph:8080 (HTTP port, not gRPC 9080).","Check that any environment variable used for the host actually resolves to a non-empty value.","Trim whitespace/quotes from the configured URL.","Validate locally: run the same URL through a URL parser or curl before restarting the toolbox."],"exampleFix":"// before\naddress: dgraph:9080\n// after\naddress: http://dgraph:8080","handlingStrategy":"validation","validationCode":"u, err := url.ParseRequestURI(cfg.Address)\nif err != nil {\n    return fmt.Errorf(\"dgraph address %q is not a valid absolute URI (use http://host:8080)\", cfg.Address)\n}\n_ = u","typeGuard":null,"tryCatchPattern":"url, err := getUrl(base, \"/health\", nil)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to get url\") {\n        return fmt.Errorf(\"check the dgraph address in your config: %w\", err)\n    }\n    return err\n}","preventionTips":["Use absolute URLs with scheme and the HTTP port (8080) in all Dgraph source configs.","Verify env-var interpolation produces a non-empty value before launch.","Add a startup smoke test that parses every configured source address."],"tags":["dgraph","url","config","validation"],"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"}