From 1dbdd5a6460a8ad2ed0f9bdd7a4dc816a1a4845b Mon Sep 17 00:00:00 2001 From: Shwetha Gururaj Date: Tue, 9 Sep 2025 11:56:04 -0400 Subject: [PATCH 1/2] Check for chunk size before api call --- actor/v7action/resource_match.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/actor/v7action/resource_match.go b/actor/v7action/resource_match.go index dc5db1c3429..a99d38f4a55 100644 --- a/actor/v7action/resource_match.go +++ b/actor/v7action/resource_match.go @@ -21,12 +21,14 @@ func (actor Actor) ResourceMatch(resources []sharedaction.V3Resource) ([]shareda ) for _, chunk := range resourceChunks { - newMatchedAPIResources, warnings, err := actor.CloudControllerClient.ResourceMatch(chunk) - allWarnings = append(allWarnings, warnings...) - if err != nil { - return nil, allWarnings, err + if len(chunk) > 0 { + newMatchedAPIResources, warnings, err := actor.CloudControllerClient.ResourceMatch(chunk) + allWarnings = append(allWarnings, warnings...) + if err != nil { + return nil, allWarnings, err + } + matchedAPIResources = append(matchedAPIResources, newMatchedAPIResources...) } - matchedAPIResources = append(matchedAPIResources, newMatchedAPIResources...) } var matchedResources []sharedaction.V3Resource From d3609b99e006e91bc46409956e2aad6c925f409b Mon Sep 17 00:00:00 2001 From: Shwetha Gururaj Date: Wed, 10 Sep 2025 12:34:34 -0400 Subject: [PATCH 2/2] Do not add to list if the current set is empty --- actor/v7action/resource_match.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/actor/v7action/resource_match.go b/actor/v7action/resource_match.go index a99d38f4a55..effc054a8ce 100644 --- a/actor/v7action/resource_match.go +++ b/actor/v7action/resource_match.go @@ -53,8 +53,10 @@ func (Actor) chunkResources(resources []sharedaction.V3Resource) [][]ccv3.Resour } if len(currentSet) == constant.MaxNumberOfResourcesForMatching || index+1 == len(resources) { - chunkedResources = append(chunkedResources, currentSet) - currentSet = []ccv3.Resource{} + if len(currentSet) > 0 { + chunkedResources = append(chunkedResources, currentSet) + currentSet = []ccv3.Resource{} + } } } return chunkedResources