{"id":"c67b18ff4e40dffe","repo":"go-redis/redis","slug":"redis-invalid-s-boolean-expected-true-false-1-0","errorCode":null,"errorMessage":"redis: invalid %s boolean: expected true/false/1/0 or an empty string, got %q","messagePattern":"redis: invalid (.+?) boolean: expected true/false/1/0 or an empty string, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"options.go","lineNumber":822,"sourceCode":"\t\t\treturn -1\n\t\t}\n\t\treturn dur\n\t}\n\tif o.err == nil {\n\t\to.err = fmt.Errorf(\"redis: invalid %s duration: %w\", name, err)\n\t}\n\treturn 0\n}\n\nfunc (o *queryOptions) bool(name string) bool {\n\tswitch s := o.string(name); s {\n\tcase \"true\", \"1\":\n\t\treturn true\n\tcase \"false\", \"0\", \"\":\n\t\treturn false\n\tdefault:\n\t\tif o.err == nil {\n\t\t\to.err = fmt.Errorf(\"redis: invalid %s boolean: expected true/false/1/0 or an empty string, got %q\", name, s)\n\t\t}\n\t\treturn false\n\t}\n}\n\nfunc (o *queryOptions) remaining() []string {\n\tif len(o.q) == 0 {\n\t\treturn nil\n\t}\n\tkeys := slices.Collect(maps.Keys(o.q))\n\tslices.Sort(keys)\n\treturn keys\n}\n\n// setupConnParams converts query parameters in u to option value in o.\nfunc setupConnParams(u *url.URL, o *Options) (*Options, error) {\n\tq := queryOptions{q: u.Query()}\n","sourceCodeStart":804,"sourceCodeEnd":840,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/options.go#L804-L840","documentation":"Recorded on the queryOptions error slot by queryOptions.bool when a boolean query parameter is not one of true/false/1/0 or empty. Boolean options (pool_fifo, read_only, route_randomly, skip_verify, etc.) accept only those literal strings; any other value is rejected with the offending token quoted.","triggerScenarios":"A URL like ?pool_fifo=yes, ?skip_verify=TRUE (uppercase is not accepted), ?route_randomly=on, or ?pool_fifo=t.","commonSituations":"Using shell-style truthy values (yes/on/t), different case, or a 1/0 variant the parser does not allow.","solutions":["Use exactly true or false (lowercase), or 1/0, or omit the parameter.","If the value is dynamic, normalise it to those literals before building the URL.","Set the boolean directly on *redis.Options instead of via the URL."],"exampleFix":"// before\nopt, err := redis.ParseURL(\"redis://localhost:6379/?pool_fifo=yes\")\n// after\nopt, err := redis.ParseURL(\"redis://localhost:6379/?pool_fifo=true\")","handlingStrategy":"validation","validationCode":"func validBoolParam(s string) bool {\n    switch s { case \"true\", \"false\", \"1\", \"0\", \"\": return true }\n    return false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exactly true/false or 1/0 for URL booleans.","Set booleans on *redis.Options directly when in doubt.","Normalise dynamic values to the accepted literals before URL building."],"tags":["config","url","validation"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}