Skip to content

Commit 5544624

Browse files
committed
Fix nil value handling in command aggregation
1 parent 28ec347 commit 5544624

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

osscluster_router.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,16 +531,16 @@ func (c *ClusterClient) setCommandValue(cmd Cmder, value interface{}) error {
531531
// If value is nil, it might mean ExtractCommandValue couldn't extract the value
532532
// but the command might have executed successfully. In this case, don't set an error.
533533
if value == nil {
534-
// Check if the original command has an error - if not, the nil value is not an error
535-
if cmd.Err() == nil {
536-
// Command executed successfully but value extraction failed
537-
// This is common for complex commands like CLUSTER SLOTS
538-
// The command already has its result set correctly, so just return
539-
return nil
540-
}
541-
// If the command does have an error, set Nil error
542-
cmd.SetErr(Nil)
543-
return Nil
534+
// ExtractCommandValue returned nil - this means the command type is not supported
535+
// in the aggregation flow. This is a programming error, not a runtime error.
536+
if cmd.Err() != nil {
537+
// Command already has an error, preserve it
538+
return cmd.Err()
539+
}
540+
// Command executed successfully but we can't extract/set the aggregated value
541+
// This indicates the command type needs to be added to ExtractCommandValue
542+
return fmt.Errorf("redis: cannot aggregate command %s: unsupported command type %d",
543+
cmd.Name(), cmd.GetCmdType())
544544
}
545545

546546
switch cmd.GetCmdType() {

0 commit comments

Comments
 (0)