@@ -117,14 +117,18 @@ func (g *ComponentGetter) GetReferencedComponentVersionsRecursive(ctx context.Co
117117
118118 // First, try to get the reference directly from the parent component version
119119 refs , err := g .GetReferencedComponentVersions (ctx , parentCV , refName )
120- if err == nil {
120+ if err != nil {
121+ return nil , fmt .Errorf ("error getting referenced component versions for %s: %w" , refName , err )
122+ }
123+
124+ if len (refs ) > 0 {
121125 return refs , nil
122126 }
123127
124128 // If not found, search recursively in all component references
125129 for _ , componentRef := range parentCV .Component .ComponentReferences {
126130 subCVs , err := g .GetReferencedComponentVersions (ctx , parentCV , componentRef .Name )
127- if err != nil {
131+ if err != nil || len ( subCVs ) == 0 {
128132 continue
129133 }
130134 for _ , subCV := range subCVs {
@@ -151,7 +155,7 @@ func (g *ComponentGetter) GetComponentVersionsForResourceRecursive(ctx context.C
151155 // If not found, search recursively in all component references
152156 for _ , componentRef := range parentCV .Component .ComponentReferences {
153157 subCVs , err := g .GetReferencedComponentVersions (ctx , parentCV , componentRef .Name )
154- if err != nil {
158+ if err != nil || len ( subCVs ) == 0 {
155159 continue
156160 }
157161 for _ , subCV := range subCVs {
0 commit comments