{"id":"f829207c9b271e95","repo":"go-redis/redis","slug":"redis-non-string-key-at-position-d-v","errorCode":null,"errorMessage":"redis: non-string key at position %d: %v","messagePattern":"redis: non-string key at position (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"osscluster_router.go","lineNumber":132,"sourceCode":"\targs := cmd.Args()\n\tfirstKeyPos := cmdFirstKeyPosWithInfo(cmd, c.cmdInfoPeek(cmd.Name()))\n\tstepCount := int(cmd.stepCount())\n\tif stepCount == 0 {\n\t\tstepCount = 1 // Default to 1 if not set\n\t}\n\n\tif firstKeyPos == 0 || firstKeyPos >= len(args) {\n\t\treturn fmt.Errorf(\"redis: multi-shard command %s has no key arguments\", cmd.Name())\n\t}\n\n\t// Group keys by slot\n\tslotMap := make(map[int][]string)\n\tkeyOrder := make([]string, 0)\n\n\tfor i := firstKeyPos; i < len(args); i += stepCount {\n\t\tkey, ok := args[i].(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"redis: non-string key at position %d: %v\", i, args[i])\n\t\t}\n\n\t\tslot := hashtag.Slot(key)\n\t\tslotMap[slot] = append(slotMap[slot], key)\n\t\tfor j := 1; j < stepCount; j++ {\n\t\t\tif i+j >= len(args) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tslotMap[slot] = append(slotMap[slot], args[i+j].(string))\n\t\t}\n\t\tkeyOrder = append(keyOrder, key)\n\t}\n\n\treturn c.executeMultiSlot(ctx, cmd, slotMap, keyOrder, policy, firstKeyPos)\n}\n\n// executeMultiSlot executes commands across multiple slots concurrently\nfunc (c *ClusterClient) executeMultiSlot(ctx context.Context, cmd Cmder, slotMap map[int][]string, keyOrder []string, policy *routing.CommandPolicy, firstKeyPos int) error {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/osscluster_router.go#L114-L150","documentation":"Error \"redis: non-string key at position %d: %v\" thrown in go-redis/redis.","triggerScenarios":"Thrown at osscluster_router.go:132 when the library encounters an invalid state.","commonSituations":"Type-check key arguments at command construction.","solutions":["Pass string keys to multi-shard commands; the position in the error shows the offending argument","Convert key arguments to strings before building the command"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}