googleapis/mcp-toolbox · error
failed to get url %v
Error message
failed to get url %v
What it means
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.
Source
Thrown at internal/sources/dgraph/dgraph.go:393
}
var unhealthyErr error
for _, info := range result {
if info.Status != "healthy" {
unhealthyErr = fmt.Errorf("dgraph instance [%v] is not in healthy state, address is %v",
info.Instance, info.Address)
} else {
return nil
}
}
return unhealthyErr
}
func getUrl(baseUrl, resource string, params url.Values) (string, error) {
u, err := url.ParseRequestURI(baseUrl)
if err != nil {
return "", fmt.Errorf("failed to get url %v", err)
}
u.Path = resource
u.RawQuery = params.Encode()
return u.String(), nil
}
func checkError(resp []byte) error {
var errResp struct {
Errors []struct {
Message string `json:"message"`
} `json:"errors"`
}
if err := json.Unmarshal(resp, &errResp); err != nil {
return fmt.Errorf("failed to unmarshal json: %v", err)
}
if len(errResp.Errors) > 0 {View on GitHub (pinned to 8cc6e09de2)
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.
Example fix
// before address: dgraph:9080 // after address: http://dgraph:8080
Defensive patterns
Strategy: validation
Validate before calling
u, err := url.ParseRequestURI(cfg.Address)
if err != nil {
return fmt.Errorf("dgraph address %q is not a valid absolute URI (use http://host:8080)", cfg.Address)
}
_ = u Try / catch
url, err := getUrl(base, "/health", nil)
if err != nil {
if strings.Contains(err.Error(), "failed to get url") {
return fmt.Errorf("check the dgraph address in your config: %w", err)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error creating request: %w
- doc %d: unexpected non-string key in input: %v
- doc %d: invalid config format at key %q: %w
- doc %d: invalid config format at key %q: expected nested for
- invalid auth URL
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/53de6e88720416fb.
Report an issue: GitHub.