{"record":{"id":"c26eb160290ad0db","repo":"redis/go-redis","slug":"redis-invalid-url-scheme-s-c26eb1","errorCode":null,"errorMessage":"redis: invalid URL scheme: %s","messagePattern":"redis: invalid URL scheme: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sentinel.go","lineNumber":441,"sourceCode":"\t}\n\treturn setupFailoverConn(u)\n}\n\nfunc setupFailoverConn(u *url.URL) (*FailoverOptions, error) {\n\to := &FailoverOptions{}\n\n\to.SentinelUsername, o.SentinelPassword = getUserPassword(u)\n\n\th, p := getHostPortWithDefaults(u)\n\to.SentinelAddrs = append(o.SentinelAddrs, net.JoinHostPort(h, p))\n\n\tswitch u.Scheme {\n\tcase \"rediss\":\n\t\to.TLSConfig = &tls.Config{ServerName: h, MinVersion: tls.VersionTLS12}\n\tcase \"redis\":\n\t\to.TLSConfig = nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"redis: invalid URL scheme: %s\", u.Scheme)\n\t}\n\n\tf := strings.FieldsFunc(u.Path, func(r rune) bool {\n\t\treturn r == '/'\n\t})\n\tswitch len(f) {\n\tcase 0:\n\t\to.DB = 0\n\tcase 1:\n\t\tvar err error\n\t\tif o.DB, err = strconv.Atoi(f[0]); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"redis: invalid database number: %q\", f[0])\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"redis: invalid URL path: %s\", u.Path)\n\t}\n\n\treturn setupFailoverConnParams(u, o)","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/sentinel.go#L423-L459","documentation":"ParseFailoverURL (via setupFailoverConn) only accepts URL schemes \"redis\" and \"rediss\" when parsing a Redis Sentinel failover connection URL. Any other scheme (e.g. \"http\", \"\", \"sentinel\", or a mistyped \"redis\" spelling) fails with this error. \"rediss\" enables TLS with a config keyed to the URL host.","triggerScenarios":"Calling redis.ParseFailoverURL with a URL whose scheme is not redis/rediss, e.g. ParseFailoverURL(\"sentinel://host:26379?addr=...\") or ParseFailoverURL(\"http://...\").","commonSituations":"Copy-pasting a connection string from a dashboard or other service that uses a non-redis scheme, forgetting the scheme prefix (empty scheme), or assuming a \"sentinel\" scheme exists for failover URLs.","solutions":["Change the URL scheme to redis:// (no TLS) or rediss:// (TLS)","Check the string for typos: redsi://, redis:/, or a missing // after the scheme all break url.Parse's scheme detection","If you need a custom scheme, pre-rewrite it with strings.Replace before calling ParseFailoverURL"],"exampleFix":"// before\nopt, err := redis.ParseFailoverURL(\"sentinel://mymaster:26379\")\n// after\nopt, err := redis.ParseFailoverURL(\"redis://mymaster:26379\")","handlingStrategy":"validation","validationCode":"u, err := url.Parse(raw)\nif err != nil { return err }\nif u.Scheme != \"redis\" && u.Scheme != \"rediss\" {\n    return fmt.Errorf(\"scheme must be redis or rediss, got %q\", u.Scheme)\n}","typeGuard":null,"tryCatchPattern":"opt, err := redis.ParseFailoverURL(raw)\nif err != nil {\n    return fmt.Errorf(\"parsing failover URL %q: %w\", raw, err)\n}","preventionTips":["Only use redis:// or rediss:// for go-redis failover URLs","Verify the scheme survives config templating (no empty scheme)","Use rediss:// when TLS is required"],"tags":["redis","sentinel","url-parsing","tls"],"backgroundTag":"invalid-url-scheme","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}