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
pull/59690/head
Michael Mandrus 3 years ago committed by GitHub
parent 7f92f1df00
commit 8152b0e1ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      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 { 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 //Get latest public dashboard to return

Loading…
Cancel
Save