{"record":{"id":"97554b5a096c793e","repo":"redis/go-redis","slug":"redis-invalid-url-path-s-97554b","errorCode":null,"errorMessage":"redis: invalid URL path: %s","messagePattern":"redis: invalid URL path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sentinel.go","lineNumber":456,"sourceCode":"\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)\n}\n\nfunc setupFailoverConnParams(u *url.URL, o *FailoverOptions) (*FailoverOptions, error) {\n\tq := queryOptions{q: u.Query()}\n\n\to.MasterName = q.string(\"master_name\")\n\to.ClientName = q.string(\"client_name\")\n\to.RouteByLatency = q.bool(\"route_by_latency\")\n\to.RouteByLatencyTolerance = q.duration(\"route_by_latency_tolerance\")\n\to.RouteRandomly = q.bool(\"route_randomly\")\n\to.ReplicaOnly = q.bool(\"replica_only\")\n\to.UseDisconnectedReplicas = q.bool(\"use_disconnected_replicas\")\n\to.Protocol = q.int(\"protocol\")\n\to.Username = q.string(\"username\")\n\to.Password = q.string(\"password\")","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/sentinel.go#L438-L474","documentation":"The URL path of a failover URL may contain at most one segment (the numeric database). If the path has more than one slash-separated segment, setupFailoverConn rejects it with this error. Empty paths are fine and mean DB 0.","triggerScenarios":"Calling ParseFailoverURL with a multi-segment path, e.g. redis://host:26379/0/extra or redis://host:26379/some/path/db.","commonSituations":"Pasting an HTTP-style URL that carries route segments in its path, or appending the master name and the DB to the path together.","solutions":["Keep only one numeric path segment: redis://host:26379/0","Move extra segments into query parameters that the parser supports (addr, db, skip_verify, etc.)","Strip the extra path components from the connection string"],"exampleFix":"// before\nopt, err := redis.ParseFailoverURL(\"redis://host:26379/0/extra\")\n// after\nopt, err := redis.ParseFailoverURL(\"redis://host:26379/0\")","handlingStrategy":"validation","validationCode":"u, err := url.Parse(raw)\nif err != nil { return err }\nif strings.Count(strings.Trim(u.Path, \"/\"), \"/\") > 0 {\n    return fmt.Errorf(\"failover URL path must have at most one segment, got %q\", u.Path)\n}","typeGuard":null,"tryCatchPattern":"opt, err := redis.ParseFailoverURL(raw)\nif err != nil { return fmt.Errorf(\"bad failover URL path %q: %w\", raw, err) }","preventionTips":["Keep the failover URL path to a single numeric segment","Move extra data into supported query parameters","Sanitize copy-pasted URLs before parsing"],"tags":["redis","sentinel","url-parsing"],"backgroundTag":"invalid-url-scheme","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}