Skip to content

Commit

Permalink
Improve error message about missing bundles
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
  • Loading branch information
m1kola committed Nov 6, 2023
1 parent aca6451 commit 97aa4d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/resolution/variablesources/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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 in catalog %q: %s", head.Name, head.Package, head.CatalogName, err)
}

// add bundle dependencies to queue for processing
Expand All @@ -119,7 +119,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, fmt.Errorf("no bundles found matching required package %q in range %q", requiredPackage.PackageName, requiredPackage.VersionRange)
}
for i := 0; i < len(packageDependencyBundles); i++ {
bundle := packageDependencyBundles[i]
Expand Down
4 changes: 2 additions & 2 deletions internal/resolution/variablesources/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" in catalog "fake-catalog"`)
assert.Nil(t, bundles)
}

Expand Down Expand Up @@ -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" in catalog "fake-catalog": no bundles found matching required package "some-package" in range ">=1.0.0 <2.0.0"`))
})

It("should return error if an inner variable source returns an error", func() {
Expand Down

0 comments on commit 97aa4d1

Please sign in to comment.