diff --git a/pkg/client/common/selection/dynamicselection/pgresolver/groupsimpl.go b/pkg/client/common/selection/dynamicselection/pgresolver/groupsimpl.go index 7606d476b7..a687661132 100644 --- a/pkg/client/common/selection/dynamicselection/pgresolver/groupsimpl.go +++ b/pkg/client/common/selection/dynamicselection/pgresolver/groupsimpl.go @@ -378,10 +378,14 @@ func (o *andOperation) and(grps []Group, index int) { if index >= len(grps) { var items []Item for _, c := range o.stack.Groups() { - items = append(items, c.group.Items()[c.index]) + groupItems := c.group.Items() + if c.index < len(groupItems) { + items = append(items, groupItems[c.index]) + } + } + if len(items) > 0 { + o.result = append(o.result, NewGroup(items)) } - g := NewGroup(items) - o.result = append(o.result, g) } else { grp := grps[index] items := grp.Items()