From b834912669681e1132718630009c1eae58f525ce Mon Sep 17 00:00:00 2001 From: Anik Bhattacharjee Date: Tue, 15 Oct 2019 11:48:56 -0400 Subject: [PATCH] Modify API to return empty struct instead of error while querrying empty bundle --- pkg/server/server.go | 5 +++++ pkg/sqlite/query.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index 81ac8959b9..5f5d790618 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -43,6 +43,11 @@ func (s *RegistryServer) GetBundle(ctx context.Context, req *api.GetBundleReques if err != nil { return nil, err } + // if the value of the `bundle` field in the OperatorBundle table is NULL, return an + // empty Bundle struct + if bundleString == "" { + return new(api.Bundle), nil + } entry := ®istry.ChannelEntry{ PackageName: req.GetPkgName(), ChannelName: req.GetChannelName(), diff --git a/pkg/sqlite/query.go b/pkg/sqlite/query.go index ed0ba7782f..2baf7c11a0 100644 --- a/pkg/sqlite/query.go +++ b/pkg/sqlite/query.go @@ -113,7 +113,7 @@ func (s *SQLQuerier) GetBundle(ctx context.Context, pkgName, channelName, csvNam } if !rows.Next() { - return "", fmt.Errorf("no bundle found for csv %s", csvName) + return "", fmt.Errorf("no entry found for csv %s", csvName) } var bundleStringSQL sql.NullString if err := rows.Scan(&bundleStringSQL); err != nil {