{"id":"59588a6e7f7907a8","repo":"go-redis/redis","slug":"too-many-arguments-59588a","errorCode":null,"errorMessage":"too many arguments","messagePattern":"too many arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sortedset_commands.go","lineNumber":318,"sourceCode":"\tcmd := NewFloatSliceCmd(ctx, args...)\n\t_ = c(ctx, cmd)\n\treturn cmd\n}\n\nfunc (c cmdable) ZPopMax(ctx context.Context, key string, count ...int64) *ZSliceCmd {\n\targs := []interface{}{\n\t\t\"zpopmax\",\n\t\tkey,\n\t}\n\n\tswitch len(count) {\n\tcase 0:\n\t\tbreak\n\tcase 1:\n\t\targs = append(args, count[0])\n\tdefault:\n\t\tcmd := NewZSliceCmd(ctx)\n\t\tcmd.SetErr(errors.New(\"too many arguments\"))\n\t\treturn cmd\n\t}\n\n\tcmd := NewZSliceCmd(ctx, args...)\n\t_ = c(ctx, cmd)\n\treturn cmd\n}\n\nfunc (c cmdable) ZPopMin(ctx context.Context, key string, count ...int64) *ZSliceCmd {\n\targs := []interface{}{\n\t\t\"zpopmin\",\n\t\tkey,\n\t}\n\n\tswitch len(count) {\n\tcase 0:\n\t\tbreak\n\tcase 1:","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/sortedset_commands.go#L300-L336","documentation":"Set on the returned *ZSliceCmd when ZPopMax is called with more than one count argument. The variadic count parameter is meant to be empty (default 1) or a single int64; passing two or more values is ambiguous and rejected client-side before contacting Redis.","triggerScenarios":"Calling ZPopMax(ctx, key, 1, 2) or spreading a slice with >1 element into count (ZPopMax(ctx, key, counts...) where len(counts) > 1). The default case 0 (pop 1) and case 1 (explicit count) are the only valid arities.","commonSituations":"Spreading a dynamic slice into the variadic count without checking its length. Copy-paste from APIs that accept multiple counts. Mistaking the variadic signature for accepting min/max bounds.","solutions":["Pass at most one count argument: ZPopMax(ctx, key) or ZPopMax(ctx, key, n).","If using a slice, extract only the first element: ZPopMax(ctx, key, counts[0]).","Validate len(count) <= 1 before the call."],"exampleFix":"// before\nclient.ZPopMax(ctx, key, 1, 2) // too many counts\n\n// after — single count or none\nclient.ZPopMax(ctx, key, 2)\n// or default of 1\nclient.ZPopMax(ctx, key)","handlingStrategy":"validation","validationCode":"func zpopMax(ctx context.Context, c *redis.Client, key string, count ...int64) *redis.ZSliceCmd {\n    if len(count) > 1 {\n        panic(\"ZPopMax accepts at most one count argument\")\n    }\n    return c.ZPopMax(ctx, key, count...)\n}","typeGuard":null,"tryCatchPattern":"cmd := c.ZPopMax(ctx, key, counts...)\nif err := cmd.Err(); err != nil && err.Error() == \"too many arguments\" {\n    // too many counts; retry with at most one\n}","preventionTips":["Pass at most one count to ZPopMax.","When spreading a slice, extract only the first element.","Validate len(count) <= 1 before the call."],"tags":["sorted-set","validation","api-misuse","client-side"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}