From 511cb0375fcf3bec098c36f70a66aecaf94200a0 Mon Sep 17 00:00:00 2001 From: Richard LT Date: Tue, 23 Jun 2020 17:06:39 +0200 Subject: [PATCH] fix(api): missing group for template when loaded from audit (#5273) --- engine/api/workflow/dao.go | 2 +- engine/api/workflowtemplate/instance.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/api/workflow/dao.go b/engine/api/workflow/dao.go index cfe6a19c00..a047c3478b 100644 --- a/engine/api/workflow/dao.go +++ b/engine/api/workflow/dao.go @@ -986,7 +986,7 @@ func checkApplication(db gorp.SqlExecutor, proj sdk.Project, w *sdk.Workflow, n appDB, err := application.LoadByName(db, proj.Key, n.Context.ApplicationName, application.LoadOptions.WithDeploymentStrategies, application.LoadOptions.WithVariables) if err != nil { if sdk.ErrorIs(err, sdk.ErrNotFound) { - return sdk.WithData(sdk.ErrNotFound, n.Context.ApplicationName) + return sdk.NewErrorFrom(sdk.WithData(sdk.ErrNotFound, n.Context.ApplicationName), "cannot find application with name: %s", n.Context.ApplicationName) } return sdk.WrapError(err, "unable to load application %s", n.Context.ApplicationName) } diff --git a/engine/api/workflowtemplate/instance.go b/engine/api/workflowtemplate/instance.go index 228453c841..e7ec57f0a1 100644 --- a/engine/api/workflowtemplate/instance.go +++ b/engine/api/workflowtemplate/instance.go @@ -149,7 +149,7 @@ func CheckAndExecuteTemplate(ctx context.Context, db *gorp.DbMap, consumer sdk.A return allMsgs, nil, sdk.NewErrorFrom(sdk.ErrWrongRequest, "could not find given workflow template") } - wt, err := LoadBySlugAndGroupID(ctx, db, templateSlug, grp.ID, LoadOptions.Default) + wt, err := LoadBySlugAndGroupID(ctx, db, templateSlug, grp.ID) if err != nil { return allMsgs, nil, sdk.NewErrorFrom(err, "could not find a template with slug %s in group %s", templateSlug, grp.Name) } @@ -160,7 +160,9 @@ func CheckAndExecuteTemplate(ctx context.Context, db *gorp.DbMap, consumer sdk.A } wt = &wta.DataAfter } - + if err := LoadOptions.Default(ctx, db, wt); err != nil { + return allMsgs, nil, err + } allMsgs = append(allMsgs, sdk.NewMessage(sdk.MsgWorkflowGeneratedFromTemplateVersion, wt.PathWithVersion())) req := sdk.WorkflowTemplateRequest{