{"id":"cf90cff643563ee9","repo":"go-redis/redis","slug":"redis-please-enter-the-command-to-be-executed","errorCode":null,"errorMessage":"redis: please enter the command to be executed","messagePattern":"redis: please enter the command to be executed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pipeline.go","lineNumber":76,"sourceCode":"\texec pipelineExecer\n\tcmds []Cmder\n}\n\nfunc (c *Pipeline) init() {\n\tc.cmdable = c.Process\n\tc.statefulCmdable = c.Process\n}\n\n// Len returns the number of queued commands.\nfunc (c *Pipeline) Len() int {\n\treturn len(c.cmds)\n}\n\n// Do queues the custom command for later execution.\nfunc (c *Pipeline) Do(ctx context.Context, args ...interface{}) *Cmd {\n\tcmd := NewCmd(ctx, args...)\n\tif len(args) == 0 {\n\t\tcmd.SetErr(errors.New(\"redis: please enter the command to be executed\"))\n\t\treturn cmd\n\t}\n\t_ = c.Process(ctx, cmd)\n\treturn cmd\n}\n\n// Process queues the cmd for later execution.\nfunc (c *Pipeline) Process(ctx context.Context, cmd Cmder) error {\n\treturn c.BatchProcess(ctx, cmd)\n}\n\n// BatchProcess queues multiple cmds for later execution.\nfunc (c *Pipeline) BatchProcess(ctx context.Context, cmd ...Cmder) error {\n\tc.cmds = append(c.cmds, cmd...)\n\treturn nil\n}\n\n// Discard resets the pipeline and discards queued commands.","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/pipeline.go#L58-L94","documentation":"Set on the returned *redis.Cmd when Pipeline.Do is called with zero arguments. Pipeline.Do queues a custom command from variadic args; with none there is no command to queue, so the cmd is returned pre-errored. This is a client-side guard, not a Redis server error.","triggerScenarios":"Calling pipe.Do(ctx) with no command name or arguments, e.g. an empty Do call on a Pipeline. Common when args are computed dynamically and the slice is empty (pipe.Do(ctx, dynamicArgs...) where dynamicArgs is nil/empty).","commonSituations":"Dynamic command building where the args slice can be empty due to upstream logic. Copy-paste from a Do(ctx, \"GET\", key) pattern with the args accidentally dropped. Loop bodies that build commands conditionally and sometimes emit nothing.","solutions":["Guard the Do call: only invoke it when you have at least one argument (the command name).","Check len(args) > 0 before pipe.Do(ctx, args...).","Review the code that assembles the args slice to ensure the command name is always included."],"exampleFix":"// before\npipe.Do(ctx, cmdArgs...) // cmdArgs is empty\n\n// after\nif len(cmdArgs) == 0 {\n    return errors.New(\"no command to execute\")\n}\npipe.Do(ctx, cmdArgs...)","handlingStrategy":"validation","validationCode":"func pipeDo(pipe redis.Pipeliner, ctx context.Context, args ...interface{}) *redis.Cmd {\n    if len(args) == 0 {\n        cmd := redis.NewCmd(ctx)\n        cmd.SetErr(errors.New(\"no command provided\"))\n        return cmd\n    }\n    return pipe.Do(ctx, args...)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check len(args) > 0 before calling Pipeline.Do.","When spreading a dynamic slice, guard against nil/empty slices.","Always include the command name as the first argument."],"tags":["pipeline","validation","api-misuse","client-side"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}