Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default :per_page parameter is ignored #137

Open
smetana opened this issue Oct 29, 2013 · 5 comments
Open

Default :per_page parameter is ignored #137

smetana opened this issue Oct 29, 2013 · 5 comments
Labels

Comments

@smetana
Copy link

smetana commented Oct 29, 2013

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.

@piotrmurach
Copy link
Owner

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

@smetana
Copy link
Author

smetana commented Oct 30, 2013

I will look into this

@rbroemeling
Copy link

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

@piotrmurach
Copy link
Owner

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?

@rbroemeling
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants