{"id":"0ef2f1a46d7e04e4","repo":"go-redis/redis","slug":"redis-command-t-does-not-have-setval-method","errorCode":null,"errorMessage":"redis: command %T does not have SetVal method","messagePattern":"redis: command %T does not have SetVal method","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"osscluster_router.go","lineNumber":979,"sourceCode":"\t\t}\n\tdefault:\n\t\t// Fallback to reflection for unknown types\n\t\treturn c.setCommandValueReflection(cmd, value)\n\t}\n\n\treturn nil\n}\n\n// setCommandValueReflection is a fallback function that uses reflection\nfunc (c *ClusterClient) setCommandValueReflection(cmd Cmder, value interface{}) error {\n\tcmdValue := reflect.ValueOf(cmd)\n\tif cmdValue.Kind() != reflect.Ptr || cmdValue.IsNil() {\n\t\treturn errInvalidCmdPointer\n\t}\n\n\tsetValMethod := cmdValue.MethodByName(\"SetVal\")\n\tif !setValMethod.IsValid() {\n\t\treturn fmt.Errorf(\"redis: command %T does not have SetVal method\", cmd)\n\t}\n\n\targs := []reflect.Value{reflect.ValueOf(value)}\n\n\tswitch cmd.(type) {\n\tcase *XAutoClaimCmd, *XAutoClaimJustIDCmd:\n\t\targs = append(args, reflect.ValueOf(\"\"))\n\tcase *ScanCmd:\n\t\targs = append(args, reflect.ValueOf(uint64(0)))\n\tcase *KeyValuesCmd, *ZSliceWithKeyCmd:\n\t\tif key, ok := value.(string); ok {\n\t\t\targs = []reflect.Value{reflect.ValueOf(key)}\n\t\t\tif _, ok := cmd.(*ZSliceWithKeyCmd); ok {\n\t\t\t\targs = append(args, reflect.ValueOf([]Z{}))\n\t\t\t} else {\n\t\t\t\targs = append(args, reflect.ValueOf([]string{}))\n\t\t\t}\n\t\t}","sourceCodeStart":961,"sourceCodeEnd":997,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/osscluster_router.go#L961-L997","documentation":"Error \"redis: command %T does not have SetVal method\" thrown in go-redis/redis.","triggerScenarios":"Thrown at osscluster_router.go:979 when the library encounters an invalid state.","commonSituations":"Run the repo's custom vet tool to catch Cmder types missing SetVal at build time.","solutions":["Implement SetVal on the custom Cmder type (required by the customvet setval rule)","Use the built-in command types that already implement SetVal"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}