keybase / keybase/keybase-issues

Pagination broken when reading messages from a channel in a big team in Chat API

Open
#4,042 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
899
Forks
40
PR merge metrics
No merged PRs in 30d

Description

The chat API will read only the latest 1000 messages per each API call. For a one-on-one chat, one reaches the next page this by setting a value for "next" and running a second query.

Following the instructions at `keybase chat api -h`, I read the first page of messages in a one-on-one chat.
```
{"method": "read",
"params": {
"options": {
"channel": {
"name": "you,them"
},
"pagination": {
"num": 1000
}}}}}
```

Some JSON ensues, ending in a pagination block.
```
"pagination": {
"next": "next_value",
"previous": "prev_value",
"num": 1000
}
}
```

One then takes next_value from the JSON result and runs a second query.
```
{"method": "read",
"params": {
"options": {
"channel": {
"name": "you,them"
},
"pagination": {
"next": "next_value",
"num": 1000
}}}}
```
This returns the second page of chat results and may be iterated until one reaches the last message. It seems to me that this same process should work for the messages in a channel in a team: however, this is not the case.

If I follow the help docs and read messages in a channel in a team as follows...
```
{"method": "read",
"params": {
"options": {
"channel": {
"name": "treehouse",
"members_type": "team",
"topic_name": "meetings",
"pagination": {
"num": 1000
}}}}}
```
... I do in fact get 1000 messages followed by a pagination block as above. However, when I take next_value from the JSON results as before and pass a second query...
```
{"method": "read",
"params": {
"options": {
"channel": {
"name": "treehouse",
"members_type": "team",
"topic_name": "meetings",
"pagination": {
"next": "next_value",
"num": 1000
}}}}}
```
... it appears that the API does not process the request. Instead, the first page of results is returned a second time.

If you attempt to incorporate the pagination function into a script or bot that has to read beyond the first page of message results, everything breaks. Maybe I am doing something wrong but everything in the available documentation suggests that pagination should work for channels in teams as it does for one-on-one chats.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the two pagination flows through the `keybase chat api -h` entry point, using the JSON requests in the report. Compare one-on-one and team-channel reads, then trace the team-channel pagination handling. Done means passing the returned `next` value returns the next page rather than repeating the first.

Written by the indexing model from the issue text.

Assessment

Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.