{"record":{"id":"8f8a9ff7e9fd911b","repo":"alibaba/open-code-review","slug":"base-url-q-must-include-a-host","errorCode":null,"errorMessage":"Base URL %q must include a host","messagePattern":"Base URL %q must include a host","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/provider_cmd.go","lineNumber":459,"sourceCode":"\tif len(key) <= 8 {\n\t\treturn \"***\"\n\t}\n\treturn key[:4] + \"***\" + key[len(key)-4:]\n}\n\n// validateBaseURL checks that a provider Base URL has an http or https scheme\n// and a non-empty host, giving the user immediate feedback rather than\n// a runtime failure when the LLM client tries to use it.\nfunc validateBaseURL(raw string) error {\n\tparsed, err := url.Parse(raw)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid Base URL %q: %w\", raw, err)\n\t}\n\tif parsed.Scheme != \"http\" && parsed.Scheme != \"https\" {\n\t\treturn fmt.Errorf(\"Base URL must use http or https scheme, got %q\", parsed.Scheme)\n\t}\n\tif parsed.Host == \"\" {\n\t\treturn fmt.Errorf(\"Base URL %q must include a host\", raw)\n\t}\n\treturn nil\n}\n","sourceCodeStart":441,"sourceCodeEnd":463,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/provider_cmd.go#L441-L463","documentation":"validateBaseURL requires a non-empty Host component; a URL like \"https://\" or \"https:///path\" parses fine but names no server, so it is rejected with this message. This prevents saving a Base URL that would produce requests with no destination.","triggerScenarios":"applyProviderField receiving a Base URL with a scheme but no host — e.g. \"https://\", \"http:///v1\", or a value reduced to only a path after bad editing.","commonSituations":"Truncated paste that lost the hostname; accidentally deleting the host while editing the path portion; templating where the host variable was empty.","solutions":["Include the full host in the Base URL, e.g. https://api.example.com/v1","Re-check the vendor's documented endpoint and paste it completely","Ensure any templated host variable is actually populated before running the set command"],"exampleFix":"// before\n$ ocr config provider set base-url \"https:///v1\"\n// error: Base URL \"https:///v1\" must include a host\n// after\n$ ocr config provider set base-url \"https://api.example.com/v1\"","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(raw)\nif u != nil && u.Host == \"\" {\n    return fmt.Errorf(\"Base URL %q needs a host, e.g. https://api.example.com\", raw)\n}","typeGuard":"func hasURLHost(raw string) bool {\n    u, err := url.Parse(raw)\n    return err == nil && u.Host != \"\"\n}","tryCatchPattern":"if err := applyProviderField(...); err != nil {\n    if strings.Contains(err.Error(), \"must include a host\") {\n        fmt.Fprintf(os.Stderr, \"hostname missing — paste the full endpoint URL\\n\")\n    }\n    return err\n}","preventionTips":["Paste the complete endpoint including hostname and path","Check templated config values resolve to non-empty hosts","Confirm the URL survives copy/paste without truncation"],"tags":["validation","url","config"],"backgroundTag":"missing-url-host","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}