From b83d5ab0222bda538abab2274cf825b584bfc55f Mon Sep 17 00:00:00 2001 From: Mikalai Radchuk Date: Fri, 3 Nov 2023 14:18:17 +0000 Subject: [PATCH] Improve error message about missing bundles Signed-off-by: Mikalai Radchuk --- internal/resolution/variablesources/bundle.go | 5 +++-- internal/resolution/variablesources/bundle_test.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/resolution/variablesources/bundle.go b/internal/resolution/variablesources/bundle.go index eebc308d9..e27c87614 100644 --- a/internal/resolution/variablesources/bundle.go +++ b/internal/resolution/variablesources/bundle.go @@ -2,6 +2,7 @@ package variablesources import ( "context" + "errors" "fmt" "sort" @@ -94,7 +95,7 @@ func MakeBundleVariables( // get bundle dependencies dependencies, err := filterBundleDependencies(allBundles, head) if err != nil { - return nil, fmt.Errorf("could not determine dependencies for bundle with id %q: %w", id, err) + return nil, fmt.Errorf("could not determine dependencies for bundle %q from package %q from catalog %q: %s", head.Name, head.Package, head.CatalogName, err) } // add bundle dependencies to queue for processing @@ -119,7 +120,7 @@ func filterBundleDependencies(allBundles []*catalogmetadata.Bundle, bundle *cata catalogfilter.InBlangSemverRange(requiredPackage.SemverRange), )) if len(packageDependencyBundles) == 0 { - return nil, fmt.Errorf("could not find package dependencies for bundle %q", bundle.Name) + return nil, errors.New("could not find package dependencies for bundle") } for i := 0; i < len(packageDependencyBundles); i++ { bundle := packageDependencyBundles[i] diff --git a/internal/resolution/variablesources/bundle_test.go b/internal/resolution/variablesources/bundle_test.go index 32da44fbd..85e67e8ac 100644 --- a/internal/resolution/variablesources/bundle_test.go +++ b/internal/resolution/variablesources/bundle_test.go @@ -194,7 +194,7 @@ func TestMakeBundleVariables_NonExistentDepedencies(t *testing.T) { installedPackages := []*olmvariables.InstalledPackageVariable{} bundles, err := variablesources.MakeBundleVariables(allBundles, requiredPackages, installedPackages) - assert.ErrorContains(t, err, `could not determine dependencies for bundle with id "fake-catalog-test-package-test-package.v1.0.0"`) + assert.ErrorContains(t, err, `could not determine dependencies for bundle "test-package.v1.0.0" from package "test-package" from catalog "fake-catalog"`) assert.Nil(t, bundles) } @@ -550,7 +550,7 @@ var _ = Describe("BundlesAndDepsVariableSource", func() { ) _, err := bdvs.GetVariables(context.TODO()) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring(`could not determine dependencies for bundle with id "fake-catalog-test-package-bundle-2": could not find package dependencies for bundle "bundle-2"`)) + Expect(err.Error()).To(ContainSubstring(`could not determine dependencies for bundle "bundle-2" from package "test-package" from catalog "fake-catalog": could not find package dependencies for bundle`)) }) It("should return error if an inner variable source returns an error", func() {