github icon indicating copy to clipboard operation
github copied to clipboard

Default :per_page parameter is ignored

Open smetana opened this issue 11 years ago • 5 comments

When API instance is created with default :per_page parameter

gh = Github.new :auto_pagination => true, :per_page => 100,... 
gh.repos.list

First request is always sent without parameters and autopagination uses default 30 page size.

smetana avatar Oct 29 '13 13:10 smetana

Hi Serge, do you have time to look into this and submit PR?

piotrmurach avatar Oct 29 '13 23:10 piotrmurach

I will look into this

smetana avatar Oct 30 '13 19:10 smetana

We just upgraded from v0.11.3 to v0.12.2 of the gem and were bit by a problem that looks very much like this: when our GitHub connection is initialized with a "default" :per_page setting of 100, branches are missing when they are listed from a repository (i.e. they just don't show up in the resultset). Without setting a "default" :per_page (i.e. if we just don't configure that part), everything is listed correctly.

The difference is that simple:

Causes some branches to be missing from the result:

Github.new do |config|
  config.auto_pagination = true
  config.oauth_token     = @@token
  config.per_page        = 100
end

Works properly (no branches missing):

Github.new do |config|
  config.auto_pagination = true
  config.oauth_token     = @@token
end

rbroemeling avatar Nov 03 '14 20:11 rbroemeling

Thanks for letting me know, this is indeed strange behaviour. Does :per_page work fine when you pass it with your request rather than with global configuration?

piotrmurach avatar Nov 03 '14 22:11 piotrmurach

github_cli sanity check

$ gcli repo branches USER REPO | fgrep ' name ' | wc -l
173

Without setting .per_page on the connection

pry(main)> github = Github.new do |config|
pry(main)*   config.auto_pagination = true  
pry(main)*   config.oauth_token     = token  
pry(main)* end  
...
pry(main)> github.repos.branches(user, repository).size
173
pry(main)> github.repos.branches(:user => user, :repo => repository).size
173
pry(main)> github.repos.branches(:user => user, :repo => repository, :per_page => 100).size
173

With setting .per_page on the connection

pry(main)> github = Github.new do |config|
pry(main)*   config.auto_pagination = true  
pry(main)*   config.oauth_token     = token  
pry(main)*   config.per_page        = 100  
pry(main)* end  
...
pry(main)> github.repos.branches(user, repository).size
103
pry(main)> github.repos.branches(:user => user, :repo => repository).size
103
pry(main)> github.repos.branches(:user => user, :repo => repository, :per_page => 100).size
173

This problem appears trivially/easily reproducible -- I've never attempted to reproduce it and failed.

rbroemeling avatar Nov 04 '14 17:11 rbroemeling