From f2182d806b9c25e715a2a8a54adb50afba716316 Mon Sep 17 00:00:00 2001 From: Rohan Sharma <117426013+RS-labhub@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:26:59 +0530 Subject: [PATCH] [MM-61097] Fix errcheck issues in server/channels/app/bot.go (#28785) Co-authored-by: Ben Schumacher --- server/.golangci.yml | 2 +- server/channels/app/bot.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/.golangci.yml b/server/.golangci.yml index 806d69b2de..290bcfbcbb 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -88,7 +88,7 @@ issues: channels/app/app_test.go|\ channels/app/authorization_test.go|\ channels/app/auto_responder_test.go|\ - channels/app/bot.go|\ + channels/app/bot_test.go|\ channels/app/brand.go|\ channels/app/busy_test.go|\ channels/app/channel.go|\ diff --git a/server/channels/app/bot.go b/server/channels/app/bot.go index 6d4af93ecc..29196f69a1 100644 --- a/server/channels/app/bot.go +++ b/server/channels/app/bot.go @@ -124,7 +124,9 @@ func (a *App) CreateBot(rctx request.CTX, bot *model.Bot) (*model.Bot, *model.Ap savedBot, nErr := a.Srv().Store().Bot().Save(bot) if nErr != nil { - a.Srv().Store().User().PermanentDelete(rctx, bot.UserId) + if err := a.Srv().Store().User().PermanentDelete(rctx, bot.UserId); err != nil { + rctx.Logger().Error("Failed to permanently delete the user after bot save failure", mlog.Err(err)) + } var appErr *model.AppError switch { case errors.As(nErr, &appErr): // in case we haven't converted to plain error. @@ -227,7 +229,9 @@ func (a *App) getOrCreateBot(rctx request.CTX, botDef *model.Bot) (*model.Bot, * //save the bot savedBot, nErr := a.Srv().Store().Bot().Save(botDef) if nErr != nil { - a.Srv().Store().User().PermanentDelete(rctx, savedBot.UserId) + if err := a.Srv().Store().User().PermanentDelete(rctx, savedBot.UserId); err != nil { + rctx.Logger().Error("Failed to permanently delete the user after bot save failure", mlog.Err(err)) + } var nAppErr *model.AppError switch { case errors.As(nErr, &nAppErr): // in case we haven't converted to plain error.