From 8152b0e1ef1d798542725e254b1b591910f74096 Mon Sep 17 00:00:00 2001 From: Michael Mandrus <41969079+mmandrus@users.noreply.github.com> Date: Fri, 2 Dec 2022 08:46:35 +0100 Subject: [PATCH] Pubdash: Verify affected rows count in database 'create' call (#59591) * make create call consistent with update and delete * use appropriate error type * update log statements * update error log for 0 affected rows --- pkg/services/publicdashboards/service/service.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/services/publicdashboards/service/service.go b/pkg/services/publicdashboards/service/service.go index 2d2dc30785f..31ebdb12d18 100644 --- a/pkg/services/publicdashboards/service/service.go +++ b/pkg/services/publicdashboards/service/service.go @@ -168,9 +168,11 @@ func (pd *PublicDashboardServiceImpl) Create(ctx context.Context, u *user.Signed }, } - _, err = pd.store.Create(ctx, cmd) + affectedRows, err := pd.store.Create(ctx, cmd) if err != nil { - return nil, ErrInternalServerError.Errorf("Create: failed to create the public dashboard: %w", err) + return nil, ErrInternalServerError.Errorf("Create: failed to create the public dashboard with Uid %s: %w", uid, err) + } else if affectedRows == 0 { + return nil, ErrInternalServerError.Errorf("Create: failed to create a database entry for public dashboard with Uid %s. 0 rows changed, no error reported.", uid) } //Get latest public dashboard to return