googleapis/mcp-toolbox · error
error creating request: %w
Error message
error creating request: %w
What it means
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.
Source
Thrown at internal/sources/dgraph/dgraph.go:349
return fmt.Errorf("no access JWT found in the response")
}
if r.Data.RefreshJWT == "" {
return fmt.Errorf("no refresh JWT found in the response")
}
hc.AccessJwt = r.Data.AccessJWT
hc.RefreshToken = r.Data.RefreshJWT
return nil
}
func (hc *DgraphClient) healthCheck() error {
url, err := getUrl(hc.baseUrl, "/health", nil)
if err != nil {
return err
}
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
return fmt.Errorf("error creating request: %w", err)
}
resp, err := hc.httpClient.Do(req)
if err != nil {
return fmt.Errorf("error performing request: %w", err)
}
defer resp.Body.Close()
data, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
var result []struct {
Instance string `json:"instance"`
Address string `json:"address"`
Status string `json:"status"`
}
View on GitHub (pinned to 8cc6e09de2)
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.
Example fix
// before baseUrl: dgraph:8080 // after baseUrl: http://dgraph:8080
Defensive patterns
Strategy: validation
Validate before calling
u, err := url.ParseRequestURI(cfg.Address)
if err != nil || u.Scheme == "" || u.Host == "" {
return fmt.Errorf("invalid dgraph baseUrl %q: must be an absolute URL like http://host:8080", cfg.Address)
} Try / catch
if err := healthCheck(ctx); err != nil {
if strings.Contains(err.Error(), "error creating request") {
// treat as configuration error: fail fast, do not retry
return fmt.Errorf("misconfigured dgraph baseUrl: %w", err)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error building req for endpoint [%v] : %v
- failed to get url %v
- error parsing base URL: %s
- base URL must include scheme and host
- invalid auth URL
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/0d91863739c99092.
Report an issue: GitHub.