{"record":{"id":"fcfe73309a402e1a","repo":"alibaba/open-code-review","slug":"base-url-must-use-http-or-https-scheme-got-q","errorCode":null,"errorMessage":"Base URL must use http or https scheme, got %q","messagePattern":"Base URL must use http or https scheme, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/provider_cmd.go","lineNumber":456,"sourceCode":"\tif key == \"\" {\n\t\treturn \"(not set)\"\n\t}\n\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":438,"sourceCodeEnd":463,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/provider_cmd.go#L438-L463","documentation":"validateBaseURL requires the Base URL's scheme to be http or https; any other scheme (ftp://, file://, or a missing scheme where url.Parse yields an empty Scheme) is rejected with this message. This prevents saving endpoints the LLM HTTP client could never reach.","triggerScenarios":"applyProviderField receiving a Base URL like \"api.example.com/v1\" (no scheme), \"ftp://...\", or \"localhost:8080\" where url.Parse's Scheme ends up not http/https.","commonSituations":"Users omitting https:// when pasting hostnames; copying non-HTTP links from vendor docs; assuming a bare host:port string is a valid URL.","solutions":["Prefix the URL with https:// (or http:// for local/insecure endpoints)","Example: change \"api.example.com/v1\" to \"https://api.example.com/v1\"","For local gateways use \"http://localhost:8080/v1\"","Re-run the provider set command after fixing the scheme"],"exampleFix":"// before\n$ ocr config provider set base-url api.example.com/v1\n// error: Base URL must use http or https scheme, got \"\"\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.Scheme != \"http\" && u.Scheme != \"https\" {\n    return fmt.Errorf(\"add http:// or https:// prefix to %q\", raw)\n}","typeGuard":"func hasHTTPScheme(raw string) bool {\n    u, err := url.Parse(raw)\n    return err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\")\n}","tryCatchPattern":"if err := applyProviderField(...); err != nil {\n    if strings.Contains(err.Error(), \"must use http or https scheme\") {\n        fmt.Fprintln(os.Stderr, \"prefix the endpoint with https://\")\n    }\n    return err\n}","preventionTips":["Always include https:// when entering endpoints","Treat bare host:port as invalid until prefixed with a scheme","Use http:// only for explicitly local/insecure gateways"],"tags":["validation","url","config"],"backgroundTag":"url-scheme-not-allowed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}