{"record":{"id":"3bc0d4105f583a0f","repo":"hibiken/asynq","slug":"asynq-unsupported-uri-scheme-q","errorCode":null,"errorMessage":"asynq: unsupported uri scheme: %q","messagePattern":"asynq: unsupported uri scheme: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"asynq.go","lineNumber":489,"sourceCode":"//\n//\tredis://[:password@]host[:port][/dbnumber]\n//\trediss://[:password@]host[:port][/dbnumber]\n//\tredis-socket://[:password@]path[?db=dbnumber]\n//\tredis-sentinel://[:password@]host1[:port][,host2:[:port]][,hostN:[:port]][/dbnumber][?master=masterName]\nfunc ParseRedisURI(uri string) (RedisConnOpt, error) {\n\tu, err := url.Parse(uri)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"asynq: could not parse redis uri: %w\", err)\n\t}\n\tswitch u.Scheme {\n\tcase \"redis\", \"rediss\":\n\t\treturn parseRedisURI(u)\n\tcase \"redis-socket\":\n\t\treturn parseRedisSocketURI(u)\n\tcase \"redis-sentinel\":\n\t\treturn parseRedisSentinelURI(u)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"asynq: unsupported uri scheme: %q\", u.Scheme)\n\t}\n}\n\nfunc parseRedisURI(u *url.URL) (RedisConnOpt, error) {\n\tvar db int\n\tvar err error\n\tvar redisConnOpt RedisClientOpt\n\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 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","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/asynq.go#L471-L507","documentation":"ParseRedisURI accepts only the schemes redis, rediss, redis-socket, and redis-sentinel; any other scheme yields this error at asynq.go:489. It reports the unsupported scheme via %q so it is easy to spot which scheme string was actually parsed.","triggerScenarios":"Calling ParseRedisURI with a URI whose parsed scheme is not one of the four supported ones, e.g. http://, memcache://, or Redis cluster-style redis+cluster:// URIs.","commonSituations":"Passing a plain hostname without a scheme (url.Parse then reports scheme as empty after splitting on ':'); using a scheme from a different client library's config; typos like rediss:// vs rediss (extra characters) or capitalized schemes from docs.","solutions":["Use one of the supported schemes: redis, rediss, redis-socket, or redis-sentinel","If no scheme is present, prefix the URI with redis:// (a bare host:port parses with an empty scheme)","For connection options not expressible as a URI, construct RedisClientOpt directly instead of ParseRedisURI"],"exampleFix":"// before\nopt, err := asynq.ParseRedisURI(\"localhost:6379\")\n// after\nopt, err := asynq.ParseRedisURI(\"redis://localhost:6379\")","handlingStrategy":"validation","validationCode":"func validateRedisScheme(uri string) error {\n    u, err := url.Parse(uri)\n    if err != nil {\n        return err\n    }\n    switch u.Scheme {\n    case \"redis\", \"rediss\", \"redis-socket\", \"redis-sentinel\":\n        return nil\n    default:\n        return fmt.Errorf(\"unsupported scheme %q\", u.Scheme)\n    }\n}","typeGuard":null,"tryCatchPattern":"opt, err := asynq.ParseRedisURI(uri)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"asynq: unsupported uri scheme\") {\n        return fmt.Errorf(\"redis URI %q must use redis/rediss/redis-socket/redis-sentinel scheme\", uri)\n    }\n    return err\n}","preventionTips":["Always include an explicit scheme in Redis URIs, even for localhost (redis://localhost:6379)","Keep a small allowlist check of schemes in your config loader","Use lowercase schemes; url.Parse does not lowercase and asynq matches exactly"],"tags":["go","redis","uri-scheme","configuration"],"backgroundTag":"invalid-enum-value","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"}