{"record":{"id":"1576216a3626f628","repo":"googleapis/mcp-toolbox","slug":"base-url-must-include-scheme-and-host","errorCode":null,"errorMessage":"base URL must include scheme and host","messagePattern":"base URL must include scheme and host","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/http/http.go","lineNumber":194,"sourceCode":"\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 {\n\t\treturn \"\", fmt.Errorf(\"error parsing URL path: %s\", err)\n\t}\n\tif relParsedURL.Scheme != \"\" || relParsedURL.Host != \"\" || relParsedURL.User != nil {\n\t\treturn \"\", fmt.Errorf(\"path must be relative and cannot override base host\")\n\t}\n\n\t// Reject dot segments before resolution\n\tfor _, segment := range strings.Split(relParsedURL.Path, \"/\") {\n\t\tif segment == \"..\" {\n\t\t\treturn \"\", fmt.Errorf(\"path cannot contain dot segments (..)\")\n\t\t}\n\t}\n","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/http/http.go#L176-L212","documentation":"After parsing, getURL requires the base URL to have both a scheme and a host so ResolveReference can build an absolute request URL. A base like \"api.example.com\" (no scheme) or \"/api\" (no host) triggers this error at Invoke time.","triggerScenarios":"The http source's baseUrl is set to a scheme-less value like \"localhost:8080/api\" or a relative path like \"/v1\", so baseParsedURL.Scheme == \"\" or Host == \"\".","commonSituations":"Omitting \"https://\" from baseUrl in tools.yaml; using a relative base intended to be completed later; documentation examples copied without the scheme.","solutions":["Prefix the source's baseUrl with its scheme, e.g. \"https://api.example.com\".","Ensure the baseUrl includes a host, not just a path.","Validate baseUrl scheme/host at source initialization to fail fast at startup rather than at Invoke."],"exampleFix":"# before\nbaseUrl: \"api.example.com/v1\"\n# after\nbaseUrl: \"https://api.example.com/v1\"","handlingStrategy":"validation","validationCode":"// Require absolute URL for the source's baseUrl\nu, err := url.Parse(baseURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"baseUrl must be absolute, e.g. https://api.example.com; got %q\", baseURL)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the scheme (https://) in baseUrl","Never set baseUrl to a relative path or bare host","Add the scheme/host check to a preflight config validation step"],"tags":["go","http","url","config"],"backgroundTag":"invalid-url-format","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"}