diff --git a/server/api/api.go b/server/api/api.go index 216a54dda..09e372247 100644 --- a/server/api/api.go +++ b/server/api/api.go @@ -1638,7 +1638,7 @@ func (a *API) handlePostSharing(w http.ResponseWriter, r *http.Request) { } if !a.app.GetClientConfig().EnablePublicSharedBoards { - a.logger.Info( + a.logger.Warn( "Attempt to turn on sharing for board via API failed, sharing off in configuration.", mlog.String("boardID", sharing.ID), mlog.String("userID", userID)) @@ -4102,7 +4102,7 @@ func (a *API) handleDeleteBoardsAndBlocks(w http.ResponseWriter, r *http.Request // Response helpers func (a *API) errorResponse(w http.ResponseWriter, api string, code int, message string, sourceError error) { - if code == http.StatusUnauthorized { + if code == http.StatusUnauthorized || code == http.StatusForbidden { a.logger.Debug("API DEBUG", mlog.Int("code", code), mlog.Err(sourceError), diff --git a/server/app/import.go b/server/app/import.go index 0f8a98a2e..cd1372d7e 100644 --- a/server/app/import.go +++ b/server/app/import.go @@ -80,7 +80,7 @@ func (a *App) ImportArchive(r io.Reader, opt model.ImportArchiveOptions) error { // import file/image; dir is the old board id boardID, ok := boardMap[dir] if !ok { - a.logger.Error("skipping orphan image in archive", + a.logger.Warn("skipping orphan image in archive", mlog.String("dir", dir), mlog.String("filename", filename), ) diff --git a/server/services/store/mattermostauthlayer/mattermostauthlayer.go b/server/services/store/mattermostauthlayer/mattermostauthlayer.go index baa925ee7..719f3258d 100644 --- a/server/services/store/mattermostauthlayer/mattermostauthlayer.go +++ b/server/services/store/mattermostauthlayer/mattermostauthlayer.go @@ -198,7 +198,7 @@ func (s *MattermostAuthLayer) GetTeam(id string) (*model.Team, error) { row := query.QueryRow() var displayName string err := row.Scan(&displayName) - if err != nil { + if err != nil && !s.IsErrNotFound(err) { s.logger.Error("GetTeam scan error", mlog.String("team_id", id), mlog.Err(err), diff --git a/server/services/store/sqlstore/board.go b/server/services/store/sqlstore/board.go index a1ce196ff..9e1116bce 100644 --- a/server/services/store/sqlstore/board.go +++ b/server/services/store/sqlstore/board.go @@ -292,7 +292,7 @@ func (s *SQLStore) insertBoard(db sq.BaseRunner, board *model.Board, userID stri } existingBoard, err := s.getBoard(db, board.ID) - if err != nil && !errors.Is(err, sql.ErrNoRows) { + if err != nil && !s.IsErrNotFound(err) { return nil, fmt.Errorf("insertBoard error occurred while fetching existing board %s: %w", board.ID, err) } diff --git a/server/services/store/sqlstore/migrate.go b/server/services/store/sqlstore/migrate.go index d60a2b918..9ea89911b 100644 --- a/server/services/store/sqlstore/migrate.go +++ b/server/services/store/sqlstore/migrate.go @@ -490,7 +490,7 @@ func (s *SQLStore) migrateTeamLessBoards() error { return err } - s.logger.Info(fmt.Sprintf("Migrating %d teamless boards to a team", len(boards))) + s.logger.Info("Migrating teamless boards to a team", mlog.Int("count", len(boards))) // cache for best suitable team for a DM. Since a DM can // contain multiple boards, caching this avoids diff --git a/server/services/store/store.go b/server/services/store/store.go index ba3d68d1a..15da5de89 100644 --- a/server/services/store/store.go +++ b/server/services/store/store.go @@ -3,11 +3,13 @@ package store import ( + "database/sql" "errors" "fmt" "time" "github.com/mattermost/focalboard/server/model" + mmModel "github.com/mattermost/mattermost-server/v6/model" ) @@ -161,6 +163,15 @@ func IsErrNotFound(err error) bool { return false } + // check if this is a store.ErrNotFound var nf *ErrNotFound - return errors.As(err, &nf) + if errors.As(err, &nf) { + return true + } + + // check if this is a sql.ErrNotFound + if errors.Is(err, sql.ErrNoRows) { + return true + } + return false } diff --git a/server/ws/plugin_adapter.go b/server/ws/plugin_adapter.go index 191a0a660..3b099e441 100644 --- a/server/ws/plugin_adapter.go +++ b/server/ws/plugin_adapter.go @@ -524,7 +524,7 @@ func (pa *PluginAdapter) BroadcastBlockDelete(teamID, blockID, boardID string) { } func (pa *PluginAdapter) BroadcastBoardChange(teamID string, board *model.Board) { - pa.logger.Info("BroadcastingBoardChange", + pa.logger.Debug("BroadcastingBoardChange", mlog.String("teamID", teamID), mlog.String("boardID", board.ID), ) @@ -550,7 +550,7 @@ func (pa *PluginAdapter) BroadcastBoardDelete(teamID, boardID string) { } func (pa *PluginAdapter) BroadcastMemberChange(teamID, boardID string, member *model.BoardMember) { - pa.logger.Info("BroadcastingMemberChange", + pa.logger.Debug("BroadcastingMemberChange", mlog.String("teamID", teamID), mlog.String("boardID", boardID), mlog.String("userID", member.UserID), @@ -566,7 +566,7 @@ func (pa *PluginAdapter) BroadcastMemberChange(teamID, boardID string, member *m } func (pa *PluginAdapter) BroadcastMemberDelete(teamID, boardID, userID string) { - pa.logger.Info("BroadcastingMemberDelete", + pa.logger.Debug("BroadcastingMemberDelete", mlog.String("teamID", teamID), mlog.String("boardID", boardID), mlog.String("userID", userID),