hibiken/asynq · error
: query param `db` should be a number
Error message
%s: query param `db` should be a number
What it means
Guard in parseRedisSocketURI: the redis-socket: URI contains a ?db= query parameter whose value is not an integer, so strconv.Atoi fails. The database number must be numeric; the URI is rejected with the 'asynq: could not parse redis socket uri' prefix.
Solutions
- Ensure the `db` query parameter in the redis socket URI is an integer, e.g. '?db=2'
- Remove the `db` query param if a non-default database is not needed
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at asynq.go:536 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hibiken/asynq@d135f1439b (2026-09-07).
Data as JSON: /api/errors/f2c1c378709a4311.
Report an issue: GitHub.
Appendix: source
Thrown at asynq.go:536
redisConnOpt.Addr = u.Host
redisConnOpt.Password = password
redisConnOpt.DB = db
return redisConnOpt, nil
}
func parseRedisSocketURI(u *url.URL) (RedisConnOpt, error) {
const errPrefix = "asynq: could not parse redis socket uri"
if len(u.Path) == 0 {
return nil, fmt.Errorf("%s: path does not exist", errPrefix)
}
q := u.Query()
var db int
var err error
if n := q.Get("db"); n != "" {
db, err = strconv.Atoi(n)
if err != nil {
return nil, fmt.Errorf("%s: query param `db` should be a number", errPrefix)
}
}
var password string
if v, ok := u.User.Password(); ok {
password = v
}
return RedisClientOpt{Network: "unix", Addr: u.Path, DB: db, Password: password}, nil
}
func parseRedisSentinelURI(u *url.URL) (RedisConnOpt, error) {
addrs := strings.Split(u.Host, ",")
master := u.Query().Get("master")
var db int
var err error
if len(u.Path) > 0 {
xs := strings.Split(strings.Trim(u.Path, "/"), "/")
db, err = strconv.Atoi(xs[0])
if err != nil {View on GitHub (pinned to d135f1439b)