diff --git a/staging/src/k8s.io/cli-runtime/pkg/resource/builder.go b/staging/src/k8s.io/cli-runtime/pkg/resource/builder.go
index <HASH>..<HASH> 100644
--- a/staging/src/k8s.io/cli-runtime/pkg/resource/builder.go
+++ b/staging/src/k8s.io/cli-runtime/pkg/resource/builder.go
@@ -824,10 +824,9 @@ func (b *Builder) visitorResult() *Result {
 			_, err := b.mappingFor(r)
 			if err != nil {
 				return &Result{err: err}
-			} else {
-				return &Result{err: fmt.Errorf("resource(s) were provided, but no name, label selector, or --all flag specified")}
 			}
 		}
+		return &Result{err: fmt.Errorf("resource(s) were provided, but no name, label selector, or --all flag specified")}
 	}
 	return &Result{err: missingResourceError}
 }
Traverse resources before giving no name error