Repository navigation
fix(slack): keep paginating past short pages until next_cursor is empty - #9465
Open
ShivamSharma43 wants to merge 1 commit into
Open
ShivamSharma43 wants to merge 1 commit into
ShivamSharma43 wants to merge 1 commit into
Conversation
The Slack collectors (conversations.list, conversations.history and conversations.replies) passed the requested `limit` as the ApiCollector PageSize. With GetNextPageCustomData set, ApiCollector stops as soon as a page has fewer items than PageSize, before looking at the cursor. Slack documents that a page can have fewer results than `limit` while more results remain, and that only an empty next_cursor marks the end, so channels, messages and thread replies after a short page were silently not collected. Give ApiCollector a PageSize of 1 (the same approach as the claude_code and cursor plugins) and keep sending the real page size as `limit`, so only an empty response_metadata.next_cursor ends the collection. The three collectors now share getSlackNextCursor and setSlackCursorQuery, and their ApiCollectorArgs are built in functions that the new test runs against a fake Slack API. The unused `offset` parameter sent to conversations.replies (which has no such parameter) is dropped, as it was derived from the pager. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Slack collectors can stop paginating too early and silently skip channels, messages and thread replies.
collectChannel(conversations.list),collectChannelMessage(conversations.history) andcollectThread(conversations.replies) pass the requestedlimit(100, 100 and 50) as theApiCollectorPageSize. WithGetNextPageCustomDataset,ApiCollector.fetchPagesSequentiallyreturns as soon as a page has fewer items thanPageSize, beforeGetNextPageCustomDatalooks at the cursor:Slack's pagination docs say: "It's possible to receive fewer results than your specified limit, even when there are additional results to retrieve", and that only an empty
next_cursormeans there are no further results. So when Slack returns a short page with a non-emptyresponse_metadata.next_cursor, the rest of the channel list, the channel history or the thread is not collected, and the subtask still succeeds.Changes:
tasks/api_client.go:slackCollectorPageSize = 1is passed asPageSize, soApiCollectornever ends the collection on a short page and only an emptynext_cursordoes. This is the same approach as theclaude_codeandcursorcollectors (PageSize: 1plus their ownlimitquery parameter). The number of items asked from Slack is still sent aslimit. The three copies of the cursor logic are replaced bygetSlackNextCursorandsetSlackCursorQuery.tasks/*_collector.go: theApiCollectorArgsare built innewChannelCollectorArgs,newChannelMessageCollectorArgsandnewThreadCollectorArgs, so they can be tested with a mock API client.collectThreadno longer sendsoffset:conversations.replieshas no such parameter, and the value came fromPager.Skip, which now grows by 1 per page.Does this close any open issues?
No issue is open for this. The bug is described above.
Screenshots
N/A
Other Information
pagination_test.goruns each collector'sApiCollectorArgsthroughApiCollectoragainst a fake Slack API that serves three short pages (2, 1 and 3 items,next_cursorset on the first two). It checks that all three pages are requested with the rightcursorandlimit, and that all 6 items are saved. With the oldPageSize(thelimit), only the first page is requested and the test fails.go test ./plugins/slack/...,go vet ./plugins/slack/...,gofmtandgolangci-lint run ./plugins/slack/...are clean (mocks generated with mockery v3.9.0 as inmake mock). Not run against a live Slack workspace.ApiCollector.fetchAsyncreturns before calling the pagination handler when a page has no items, so a page with zero items and a non-emptynext_cursorstill ends the collection. Fixing that needs a change in the shared helper.pr-type/bug-fix.Co-Authored-By:trailer.🤖 Generated with Claude Code