{"record":{"id":"f2c1c378709a4311","repo":"hibiken/asynq","slug":"s-query-param-db-should-be-a-number","errorCode":null,"errorMessage":"%s: query param `db` should be a number","messagePattern":"(.+?): query param `db` should be a number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"asynq.go","lineNumber":536,"sourceCode":"\tredisConnOpt.Addr = u.Host\n\tredisConnOpt.Password = password\n\tredisConnOpt.DB = db\n\n\treturn redisConnOpt, nil\n}\n\nfunc parseRedisSocketURI(u *url.URL) (RedisConnOpt, error) {\n\tconst errPrefix = \"asynq: could not parse redis socket uri\"\n\tif len(u.Path) == 0 {\n\t\treturn nil, fmt.Errorf(\"%s: path does not exist\", errPrefix)\n\t}\n\tq := u.Query()\n\tvar db int\n\tvar err error\n\tif n := q.Get(\"db\"); n != \"\" {\n\t\tdb, err = strconv.Atoi(n)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"%s: query param `db` should be a number\", errPrefix)\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 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 {","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/asynq.go#L518-L554","documentation":"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.","triggerScenarios":"Thrown at asynq.go:536 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"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"}