Skip to content

fix: auto-paginate channel list --all across conversations.list pages#14

Merged
jonathanlam merged 1 commit into
mainfrom
fix/channel-list-all-pagination
Jul 7, 2026
Merged

fix: auto-paginate channel list --all across conversations.list pages#14
jonathanlam merged 1 commit into
mainfrom
fix/channel-list-all-pagination

Conversation

@jonathanlam

@jonathanlam jonathanlam commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

channel list --all only ever made a single call to conversations.list, but Slack frequently shards results well below the requested --limit even in modest workspaces — while still returning a next_cursor. This meant --all silently under-reported the workspace's channels despite its name. In production this caused a channel lookup for an internal customer alerting channel to fail (only 15 of the workspace's channels came back on page one), skipping a scheduled Slack post entirely.

  • ListChannels now auto-follows the cursor internally and merges every page when All=true and no explicit --cursor is passed
  • An explicit --cursor still fetches a single page (manual/resume use)
  • Added a maxAutoPaginatePages safety cap (50 pages); if hit, the result carries truncated: true plus a resumable next_cursor
  • Updated flag help text to describe the new behavior

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... — added internal/slack/channels_test.go covering: merging across sharded pages, explicit-cursor single-page behavior, and the truncation cap

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@jonathanlam jonathanlam added the patch Patch version updates (fixes) label Jul 7, 2026
@jonathanlam jonathanlam force-pushed the fix/channel-list-all-pagination branch from 977d847 to c68617b Compare July 7, 2026 09:47
Slack's conversations.list frequently returns far fewer channels per
page than the requested limit, even in modest workspaces, while still
handing back a next_cursor. `channel list --all` only ever made a
single call, so it silently under-reported the workspace's channels
despite the flag's name promising otherwise.

ListChannels now follows the cursor internally until exhausted (or a
50-page safety cap, surfaced via a new `truncated` field) when --all is
set and no explicit --cursor is given. Passing --cursor still fetches a
single page for manual/resume use.
@jonathanlam jonathanlam force-pushed the fix/channel-list-all-pagination branch from c68617b to 01dc7ab Compare July 7, 2026 09:50
@jonathanlam jonathanlam marked this pull request as ready for review July 7, 2026 09:51
@jonathanlam jonathanlam merged commit 814a5e7 into main Jul 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Patch version updates (fixes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant