piotrmurach / github

Ruby interface to GitHub API
https://piotrmurach.github.io/github
MIT License
1.15k stars 316 forks source link

Can't List Organization's Repos #134

Open brotatos opened 11 years ago

brotatos commented 11 years ago

After I run this script:

require 'github_api'                                     

github = Github.new oauth_token: `git config github.token`
github.repos.list org: 'iFixit'                           

I get this error:

/home/robin/build/lib/ruby/gems/1.9.1/gems/multi_json-1.8.0/lib/multi_json/adapters/yajl.rb:11:in `parse': lexical error: invalid char in json text. (MultiJson::LoadError)
                                       <html><body><h1>400 Bad request
                     (right here) ------^
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/multi_json-1.8.0/lib/multi_json/adapters/yajl.rb:11:in `load'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/multi_json-1.8.0/lib/multi_json/adapter.rb:20:in `load'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/multi_json-1.8.0/lib/multi_json.rb:120:in `load'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/jsonable.rb:12:in `decode'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/error/service_error.rb:26:in `decode_body'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/error/service_error.rb:33:in `parse_body'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/error/service_error.rb:20:in `parse_response'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/error/service_error.rb:15:in `initialize'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/error/bad_request.rb:10:in `initialize'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/response/raise_error.rb:14:in `new'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/response/raise_error.rb:14:in `on_complete'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/response.rb:9:in `block in call'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/response.rb:63:in `on_complete'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/response.rb:8:in `call'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/response.rb:8:in `call'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/response.rb:8:in `call'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/request/oauth2.rb:24:in `call'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/request/url_encoded.rb:14:in `call'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/request/multipart.rb:13:in `call'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/request/jsonize.rb:18:in `call'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/connection.rb:253:in `run_request'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/faraday-0.8.8/lib/faraday/connection.rb:106:in `get'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/request.rb:44:in `request'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/request.rb:12:in `get_request'
    from /home/robin/build/lib/ruby/gems/1.9.1/gems/github_api-0.10.2/lib/github_api/repos.rb:149:in `list'
    from ./testing.rb:6:in `<main>'
serv commented 11 years ago

I started to get something similar as well today.

Here is the error message.

MultiJson::LoadError
795: unexpected token at '<html><body><h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.
</body></html>

I get this message when I do this.

github = Github.new(:oauth_token => '89abc...........')
commits = github.repos.commits.all('big-corp-name', 'some-repo-name')

My Ruby version is ruby 2.0.0p247 and rails is Rails 3.2.13

serv commented 11 years ago

I also noticed that this problem occurs intermittently. It works one minute and stops working the next and suddenly work again.

jmtame commented 9 years ago

I can't get any of the repos for one of my orgs. It's only showing my public repos. I can't access scopes either.

CpuID commented 9 years ago

I noticed that this fails when using user and oauth_token on the Github.new call. If you try something like:

github = Github.new do |config|
  config.basic_auth = "#{user}:#{oauth_token}"
end

You will get all repositories as expected.

pillarsdotnet commented 2 years ago

We have two organizations. Some repos were created in org "A" and subsequently forked to org "B". Some repos were created in org "B" and subsequently forked to org "A".

When I list all repos in org "A" I don't find the forked copies of repos that originated with org "B".