Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be tolerant of the the end key not existing in a /messages response #489

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/msc2716_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,6 @@ func paginateUntilMessageCheckOff(t *testing.T, c *client.CSAPI, roomID string,
}))
callCounter++
messsageResBody := client.ParseJSON(t, messagesRes)
messageResEnd = client.GetJSONFieldStr(t, messsageResBody, "end")
// Since the original body can only be read once, create a new one from the body bytes we just read
messagesRes.Body = ioutil.NopCloser(bytes.NewBuffer(messsageResBody))

Expand Down Expand Up @@ -1294,6 +1293,12 @@ func paginateUntilMessageCheckOff(t *testing.T, c *client.CSAPI, roomID string,
if len(workingExpectedEventIDMap) == 0 {
return
}

// Since this will throw an error if they key does not exist, do this at the end of
// the loop. It's a valid scenario to be at the end of the room and have no more to
// paginate so we want to make sure the `return` above runs when we've found all of
// the expected events.
messageResEnd = client.GetJSONFieldStr(t, messsageResBody, "end")
Comment on lines +1297 to +1301
Copy link
Contributor Author

@MadLittleMods MadLittleMods Oct 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing this might be some Synapse change since I haven't noticed this before (nothing obvious in the changelog) 🤔

But it is part of the spec:

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 any more events), this property is omitted from the response.

-- https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidmessages

}
}

Expand Down