From 9a763682f9cf6b032ab2614c144dd82627615de2 Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Thu, 17 Jun 2021 10:19:51 +0100 Subject: [PATCH] handle error properly if template doesn't exist in the db --- plugin/converter/template.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin/converter/template.go b/plugin/converter/template.go index dcd7aae0..3f151310 100644 --- a/plugin/converter/template.go +++ b/plugin/converter/template.go @@ -18,6 +18,7 @@ package converter import ( "context" + "database/sql" "errors" "regexp" "strings" @@ -63,12 +64,12 @@ func (p *templatePlugin) Convert(ctx context.Context, req *core.ConvertArgs) (*c } // get template from db template, err := p.templateStore.FindName(ctx, templateArgs.Load, req.Repo.Namespace) - if err != nil { - return nil, nil - } - if template == nil { + if err == sql.ErrNoRows { return nil, ErrTemplateNotFound } + if err != nil { + return nil, err + } // Check if file is of type Starlark if strings.HasSuffix(templateArgs.Load, ".script") || strings.HasSuffix(templateArgs.Load, ".star") ||