From 09b1e69c0fa0d915290411274861aee04191cab6 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Thu, 13 Mar 2025 11:58:18 -0600 Subject: [PATCH] backfill: fix NPE if no messages found Signed-off-by: Sumner Evans --- pkg/connector/backfill.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/connector/backfill.go b/pkg/connector/backfill.go index 65fad94e..39549f37 100644 --- a/pkg/connector/backfill.go +++ b/pkg/connector/backfill.go @@ -254,7 +254,9 @@ func (t *TelegramClient) FetchMessages(ctx context.Context, fetchParams bridgev2 // If the first message is the last read message, mark the chat as read // during backfill. - markRead := fetchParams.Forward && portal.Metadata.(*PortalMetadata).ReadUpTo == messages[0].GetID() + markRead := fetchParams.Forward && + len(messages) > 0 && + portal.Metadata.(*PortalMetadata).ReadUpTo == messages[0].GetID() var cursor networkid.PaginationCursor if len(messages) > 0 {