{"record":{"id":"7a9dbfb8ff3f9004","repo":"hibiken/asynq","slug":"asynq-could-not-parse-redis-sentinel-uri-databas","errorCode":null,"errorMessage":"asynq: could not parse redis sentinel uri: database number should be the first segment of the path","messagePattern":"asynq: could not parse redis sentinel uri: database number should be the first segment of the path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"asynq.go","lineNumber":555,"sourceCode":"\t\t}\n\t}\n\tvar password string\n\tif v, ok := u.User.Password(); ok {\n\t\tpassword = v\n\t}\n\treturn RedisClientOpt{Network: \"unix\", Addr: u.Path, DB: db, Password: password}, nil\n}\n\nfunc parseRedisSentinelURI(u *url.URL) (RedisConnOpt, error) {\n\taddrs := strings.Split(u.Host, \",\")\n\tmaster := u.Query().Get(\"master\")\n\tvar db int\n\tvar err error\n\tif len(u.Path) > 0 {\n\t\txs := strings.Split(strings.Trim(u.Path, \"/\"), \"/\")\n\t\tdb, err = strconv.Atoi(xs[0])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"asynq: could not parse redis sentinel uri: database number should be the first segment of the path\")\n\t\t}\n\t}\n\tvar password string\n\tif v, ok := u.User.Password(); ok {\n\t\tpassword = v\n\t}\n\treturn RedisFailoverClientOpt{MasterName: master, SentinelAddrs: addrs, SentinelPassword: password, DB: db}, nil\n}\n\n// ResultWriter is a client interface to write result data for a task.\n// It writes the data to the redis instance the server is connected to.\ntype ResultWriter struct {\n\tid     string // task ID this writer is responsible for\n\tqname  string // queue name the task belongs to\n\tbroker base.Broker\n\tctx    context.Context // context associated with the task\n}\n","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/asynq.go#L537-L573","documentation":"Guard in parseRedisSentinelURI: the redis-sentinel: URI has a path whose first segment is not a number (e.g. /foo or /abc/1). Per the URI format, the database number must be the first path segment, so strconv.Atoi fails and the URI is rejected.","triggerScenarios":"Thrown at asynq.go:555 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the first path segment of the sentinel URI a valid integer database number, e.g. 'redis-sentinel:host:26379/2?master=mymaster'","Remove the path entirely if the default database (0) is desired, since an empty path skips parsing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d135f1439bee74e989b7f9b41ecd542cc87f024a","analyzedAt":"2026-09-07T19:02:34.660Z","contentChangedAt":"2026-09-07T19:02:34.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}