{"record":{"id":"48fac293969e6626","repo":"googleapis/mcp-toolbox","slug":"error-parsing-url-s","errorCode":null,"errorMessage":"error parsing URL: %s","messagePattern":"error parsing URL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/http/http.go","lineNumber":181,"sourceCode":"\t\t\tif v == nil {\n\t\t\t\treturn \"\"\n\t\t\t}\n\t\t\treturn url.PathEscape(fmt.Sprintf(\"%v\", v))\n\t\t},\n\t\t\"queryEscape\": func(v any) string {\n\t\t\tif s, ok := v.(string); ok {\n\t\t\t\treturn url.QueryEscape(s)\n\t\t\t}\n\t\t\tif v == nil {\n\t\t\t\treturn \"\"\n\t\t\t}\n\t\t\treturn url.QueryEscape(fmt.Sprintf(\"%v\", v))\n\t\t},\n\t}\n\n\ttempl, err := template.New(\"url\").Funcs(funcMap).Parse(path)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error parsing URL: %s\", err)\n\t}\n\tvar templatedPath bytes.Buffer\n\terr = templ.Execute(&templatedPath, pathParamsMap)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error replacing pathParams: %s\", err)\n\t}\n\n\tbaseParsedURL, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error parsing base URL: %s\", err)\n\t}\n\tif baseParsedURL.Scheme == \"\" || baseParsedURL.Host == \"\" {\n\t\treturn \"\", fmt.Errorf(\"base URL must include scheme and host\")\n\t}\n\n\trelativePath := templatedPath.String()\n\trelParsedURL, err := url.Parse(relativePath)\n\tif err != nil {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/http/http.go#L163-L199","documentation":"The tool's \"path\" is treated as a Go text/template that is rendered with path params before being joined to the source's base URL. This error wraps any template.Parse failure, meaning the path string is not syntactically valid template syntax.","triggerScenarios":"A path value contains malformed template syntax, e.g. an unclosed {{ or an invalid pipeline such as \"/users/{{.id\" or \"/items/{{if}}\", passed to getURL during Invoke.","commonSituations":"Paths containing literal braces that weren't intended as templates (JSON snippets pasted into path); forgetting to escape \"{{\" as a literal; typos in template actions; user-supplied path values with special characters.","solutions":["Fix the template syntax in the tool's \"path\" field (close all {{ }} actions).","Escape literal braces in the path (use {{\"{\"}} or avoid braces entirely).","If path values come from users, validate/reject unescaped template delimiters before Invoke."],"exampleFix":"// before\npath: \"/users/{{.id\"\n// after\npath: \"/users/{{.id}}\"","handlingStrategy":"try-catch","validationCode":"// Validate the path template parses before configuring the tool\n_, err := template.New(\"url\").Parse(toolPath)\nif err != nil {\n    return fmt.Errorf(\"invalid path template %q: %w\", toolPath, err)\n}","typeGuard":null,"tryCatchPattern":"urlString, err := getURL(baseURL, path, pathParams, queryParams, defaultQuery, paramsMap)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"error parsing URL\") {\n        return nil, fmt.Errorf(\"malformed path template %q: %w\", path, err)\n    }\n    return nil, err\n}","preventionTips":["Keep literal braces out of the path or escape them for Go templates","Close every {{ }} action and test templates with sample param values","Validate path templates at config-load time, not only at invoke time"],"tags":["go","http","template","url"],"backgroundTag":"url-template-parse-error","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}