{"id":"a3659746195483a1","repo":"go-redis/redis","slug":"redis-invalid-url-scheme-s-a36597","errorCode":null,"errorMessage":"redis: invalid URL scheme: %s","messagePattern":"redis: invalid URL scheme: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"osscluster.go","lineNumber":361,"sourceCode":"\t// setup username, password, and other configurations\n\to, err = setupClusterConn(u, h, o)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn o, nil\n}\n\n// setupClusterConn gets the username and password from the URL and the query parameters.\nfunc setupClusterConn(u *url.URL, host string, o *ClusterOptions) (*ClusterOptions, error) {\n\tswitch u.Scheme {\n\tcase \"rediss\":\n\t\to.TLSConfig = &tls.Config{ServerName: host}\n\t\tfallthrough\n\tcase \"redis\":\n\t\to.Username, o.Password = getUserPassword(u)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"redis: invalid URL scheme: %s\", u.Scheme)\n\t}\n\n\t// retrieve the configuration from the query parameters\n\to, err := setupClusterQueryParams(u, o)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn o, nil\n}\n\n// setupClusterQueryParams converts query parameters in u to option value in o.\nfunc setupClusterQueryParams(u *url.URL, o *ClusterOptions) (*ClusterOptions, error) {\n\tq := queryOptions{q: u.Query()}\n\n\to.Protocol = q.int(\"protocol\")\n\to.ClientName = q.string(\"client_name\")\n\to.MaxRedirects = q.int(\"max_redirects\")","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/osscluster.go#L343-L379","documentation":"Returned by setupClusterConn (used by ParseClusterURL) when the URL scheme is neither redis nor rediss. Cluster URLs do not support unix://, so the accepted set is narrower than the standalone ParseURL.","triggerScenarios":"Calling redis.ParseClusterURL with a scheme like unix://, http://, or a bare host:port. The default branch of the switch in setupClusterConn fires for anything but redis/rediss.","commonSituations":"Reusing a standalone REDIS_URL (which may be unix://) for a cluster client, omitting the scheme, or pasting an HTTP-style URL.","solutions":["Use redis:// or rediss:// for the cluster URL.","If you have a list of seed nodes, build *redis.ClusterOptions{Addrs: [...]} directly.","For unix sockets, construct ClusterOptions manually (cluster URLs do not support the unix scheme)."],"exampleFix":"// before\nopt, err := redis.ParseClusterURL(\"unix:///var/run/redis.sock\")\n// after\nopt, err := redis.ParseClusterURL(\"redis://node1:7000\")","handlingStrategy":"validation","validationCode":"func validClusterScheme(rawURL string) bool {\n    u, err := url.Parse(rawURL); if err != nil { return false }\n    return u.Scheme == \"redis\" || u.Scheme == \"rediss\"\n}","typeGuard":"func isClusterURL(rawURL string) bool {\n    u, err := url.Parse(rawURL); if err != nil { return false }\n    return u.Scheme == \"redis\" || u.Scheme == \"rediss\"\n}","tryCatchPattern":null,"preventionTips":["Use redis:// or rediss:// for cluster URLs (unix:// is not supported).","For unix sockets or odd setups, build ClusterOptions{Addrs:...} directly.","Keep standalone and cluster REDIS_URL env vars distinct."],"tags":["config","url","cluster","validation"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}