From d081ae748759b9fe903cd453179593d8227a46a0 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 25 Nov 2025 14:28:23 -0600 Subject: [PATCH 1/2] Keep paginating until no `end` --- tests/csapi/room_messages_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/csapi/room_messages_test.go b/tests/csapi/room_messages_test.go index 13c0e32d..c48da856 100644 --- a/tests/csapi/room_messages_test.go +++ b/tests/csapi/room_messages_test.go @@ -458,6 +458,11 @@ func _sendAndTestMessageHistory( firstEventIndex, lastEventIndex, ) + // Keep paginating until we reach the start of the room (no `end` property is + // returned). + // + // > Note that an empty `chunk` does not necessarily imply that no more events are + // > available. Clients should continue to paginate until no `end` property is returned. endTokenRes := gjson.GetBytes(messagesResBody, "end") // "`end`: If no further events are available (either because we have reached the // start of the timeline, or because the user does not have permission to see @@ -466,12 +471,6 @@ func _sendAndTestMessageHistory( break } fromToken = endTokenRes.Str - - // Or if we don't see any more events, we will assume that we reached the - // start of the room. No more to paginate. - if len(actualEventIDsFromRequest) == 0 { - break - } } // Put them in chronological order to match the expected list From 3bb4e7fff1414bc335c2c7378f402faad5d0333c Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 26 Nov 2025 09:40:49 -0600 Subject: [PATCH 2/2] Link to spec --- tests/csapi/room_messages_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/csapi/room_messages_test.go b/tests/csapi/room_messages_test.go index c48da856..4900c063 100644 --- a/tests/csapi/room_messages_test.go +++ b/tests/csapi/room_messages_test.go @@ -463,6 +463,8 @@ func _sendAndTestMessageHistory( // // > Note that an empty `chunk` does not necessarily imply that no more events are // > available. Clients should continue to paginate until no `end` property is returned. + // > + // > https://spec.matrix.org/v1.16/client-server-api/#get_matrixclientv3roomsroomidmessages endTokenRes := gjson.GetBytes(messagesResBody, "end") // "`end`: If no further events are available (either because we have reached the // start of the timeline, or because the user does not have permission to see