googleapis/mcp-toolbox · error
error parsing URL path: %s
Error message
error parsing URL path: %s
What it means
The templated tool path must parse as a relative URL: getURL parses the rendered path with net/url.Parse and wraps any parse failure as "error parsing URL path". Failures here indicate the path (after parameter substitution) is not a valid URL reference.
Source
Thrown at internal/tools/http/http.go:200
}
var templatedPath bytes.Buffer
err = templ.Execute(&templatedPath, pathParamsMap)
if err != nil {
return "", fmt.Errorf("error replacing pathParams: %s", err)
}
baseParsedURL, err := url.Parse(baseURL)
if err != nil {
return "", fmt.Errorf("error parsing base URL: %s", err)
}
if baseParsedURL.Scheme == "" || baseParsedURL.Host == "" {
return "", fmt.Errorf("base URL must include scheme and host")
}
relativePath := templatedPath.String()
relParsedURL, err := url.Parse(relativePath)
if err != nil {
return "", fmt.Errorf("error parsing URL path: %s", err)
}
if relParsedURL.Scheme != "" || relParsedURL.Host != "" || relParsedURL.User != nil {
return "", fmt.Errorf("path must be relative and cannot override base host")
}
// Reject dot segments before resolution
for _, segment := range strings.Split(relParsedURL.Path, "/") {
if segment == ".." {
return "", fmt.Errorf("path cannot contain dot segments (..)")
}
}
// Create URL based on BaseURL and Path
// Attach query parameters
parsedURL := baseParsedURL.ResolveReference(relParsedURL)
// Verify final path stays within base path scope
basePath := baseParsedURL.PathView on GitHub (pinned to 8cc6e09de2)
Solutions
- Wrap path-param interpolations with the provided "pathEscape" template function, e.g. {{.id | pathEscape}}.
- Sanitize or reject invalid characters in path param values before invocation.
- Check the tool's static "path" for typos such as malformed percent-encodings or stray whitespace.
Example fix
// before
path: "/files/{{.name}}"
// after
path: "/files/{{.name | pathEscape}}" Defensive patterns
Strategy: validation
Validate before calling
// Verify rendered path parses as a relative URL before invoking
rel, err := url.Parse(renderedPath)
if err != nil {
return fmt.Errorf("rendered path %q is not a valid URL reference: %w", renderedPath, err)
} Try / catch
urlString, err := getURL(baseURL, path, pathParams, queryParams, defaultQuery, paramsMap)
if err != nil {
if strings.HasPrefix(err.Error(), "error parsing URL path") {
return nil, fmt.Errorf("rendered path invalid; check path param values: %w", err)
}
return nil, err
} Prevention
- Apply pathEscape to every interpolated path param value
- Reject or sanitize spaces, control characters, and invalid %-sequences in param values
- Smoke-test each http tool with edge-case param values (spaces, unicode, slashes)
When it happens
Trigger: A rendered path containing invalid characters — e.g. raw spaces, invalid percent-escapes like "%zz", or control characters injected via an unsanitized path param — makes url.Parse of the relative path fail during Invoke.
Common situations: User/LLM-supplied path parameter values containing spaces or malformed escapes interpolated into the path without pathEscape; copy-pasted paths with trailing whitespace or invisible characters.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- error parsing URL: %s
- error replacing pathParams: %s
- failed to create request: %w
- error parsing base URL: %s
- base URL must include scheme and host
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/0bdf8fe75fe6860d.
Report an issue: GitHub.