Skip to content

[BUG]: Paginate method yields stale data #1786

@JSFernandes

Description

@JSFernandes

What happened?

I was using the Octokit gem to iterate through issues with a given block:

client.paginate('/repos/rails/rails/issues') do |batch|
  puts "Batch from #{batch.first.number} to #{batch.last.number}"
end

This was always yielding the same batch to the block. I then investigated the source code and this indeed the case:

yield(data, @last_response)

data is never modified, yet always yielded to the block. It will always correspond to the data from the initial request.

Assuming that this isn't intentional, may I work on a fix for it?

PS: The documentation for this also looks incorrect or outdated https://docs.github.com/en/rest/guides/scripting-with-the-rest-api-and-ruby?apiVersion=2022-11-28#making-paginated-requests

Versions

Octokit gem 10.0.0
Ruby version 3.3.4

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    🆕 Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions