From ed5ff6456a5385fc238c3282d757017571ce9802 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Wed, 24 Aug 2022 12:21:11 +0300 Subject: [PATCH] Ensure settings map is always initialized Without this, if settings are not found in account data (`M_NOT_FOUND`), we won't initialize the map and we'll panic later: > assignment to entry in nil map Breaking settings for all new rooms is definitely not what we inteded. Likely a regression since 726bc95c26d90, but related to fcac0a202d84 as well. --- bot/data.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/data.go b/bot/data.go index 400cd01..3b23a67 100644 --- a/bot/data.go +++ b/bot/data.go @@ -161,7 +161,7 @@ func (b *Bot) getSettings(ctx context.Context, roomID id.RoomID) (settings, erro span := sentry.StartSpan(ctx, "http.server", sentry.TransactionName("getSettings")) defer span.Finish() - var config settings + config := settings{} err := b.lp.GetClient().GetRoomAccountData(roomID, settingskey, &config) if err != nil { if strings.Contains(err.Error(), "M_NOT_FOUND") {