sumoheavy / jira-ruby

A Ruby gem for the JIRA REST API
MIT License
657 stars 411 forks source link

Issue All error #69

Closed bliaxiong closed 8 years ago

bliaxiong commented 10 years ago

I'm getting an error when running 'client.Issue.all' when running code in the console. Any help is greatly appreciative.

JRuby 1.7.10 Mac

Trace:

jruby-1.7.10 :029 > client.Issue.all NoMethodError: undefined method split' for :expand:Symbol from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1598:incapitalize' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1591:in each_capitalized' from org/jruby/RubyHash.java:1338:ineach' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1590:in each_capitalized' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:2081:inwrite_header' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1933:in exec' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1325:intransport_request' from org/jruby/RubyKernel.java:1282:in catch' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1324:intransport_request' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1301:in request' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:inrequest' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1294:in request' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:745:instart' from /Users/bxiong/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/net/http.rb:1292:in request' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:inrequest' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/jira-ruby-0.1.8/lib/jira/http_client.rb:22:in make_request' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/jira-ruby-0.1.8/lib/jira/request_client.rb:13:inrequest' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/jira-ruby-0.1.8/lib/jira/client.rb:151:in request' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/jira-ruby-0.1.8/lib/jira/client.rb:130:inget' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/jira-ruby-0.1.8/lib/jira/resource/issue.rb:37:in all' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/jira-ruby-0.1.8/lib/jira/base_factory.rb:33:inall' from (irb):29:in evaluate' from org/jruby/RubyKernel.java:1119:ineval' from org/jruby/RubyKernel.java:1519:in loop' from org/jruby/RubyKernel.java:1282:incatch' from org/jruby/RubyKernel.java:1282:in catch' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/railties-3.2.17/lib/rails/commands/console.rb:47:instart' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/railties-3.2.17/lib/rails/commands/console.rb:8:in start' from /Users/bxiong/.rvm/gems/jruby-1.7.10@test/gems/railties-3.2.17/lib/rails/commands.rb:41:in(root)' from org/jruby/RubyKernel.java:1083:in require' from script/rails:6:in(root)'jruby-1.7.10 :030 >

solarkennedy commented 10 years ago

I can confirm, I have this issue as well. Projects.all seems to work ok for me.

I can reproduce with ruby 1.9.1 and 2.0. I'm on Jira 6.2

bobbrodie commented 10 years ago

This is interesting. I don't know offhand that we'll be able to fix this for jruby 1.7, but I'm definitely looking into it for >=1.9.x. If anyone else sorts it first I'll merge it in right away.

solarkennedy commented 10 years ago

Here is my trace:

/usr/lib/ruby/1.9.1/net/http.rb:1591:in `capitalize': undefined method `split' for :expand:Symbol (NoMethodError)
    from /usr/lib/ruby/1.9.1/net/http.rb:1584:in `block in each_capitalized'
    from /usr/lib/ruby/1.9.1/net/http.rb:1583:in `each'
    from /usr/lib/ruby/1.9.1/net/http.rb:1583:in `each_capitalized'
    from /usr/lib/ruby/1.9.1/net/http.rb:2074:in `write_header'
    from /usr/lib/ruby/1.9.1/net/http.rb:1926:in `exec'
    from /usr/lib/ruby/1.9.1/net/http.rb:1318:in `block in transport_request'
    from /usr/lib/ruby/1.9.1/net/http.rb:1317:in `catch'
    from /usr/lib/ruby/1.9.1/net/http.rb:1317:in `transport_request'
    from /usr/lib/ruby/1.9.1/net/http.rb:1294:in `request'
    from /usr/lib/ruby/1.9.1/net/http.rb:1287:in `block in request'
    from /usr/lib/ruby/1.9.1/net/http.rb:746:in `start'
    from /usr/lib/ruby/1.9.1/net/http.rb:1285:in `request'
    from /var/lib/gems/1.9.1/gems/jira-ruby-0.1.9/lib/jira/http_client.rb:22:in `make_request'
    from /var/lib/gems/1.9.1/gems/jira-ruby-0.1.9/lib/jira/request_client.rb:13:in `request'
    from /var/lib/gems/1.9.1/gems/jira-ruby-0.1.9/lib/jira/client.rb:155:in `request'
    from /var/lib/gems/1.9.1/gems/jira-ruby-0.1.9/lib/jira/client.rb:134:in `get'
    from /var/lib/gems/1.9.1/gems/jira-ruby-0.1.9/lib/jira/resource/issue.rb:37:in `all'
    from /var/lib/gems/1.9.1/gems/jira-ruby-0.1.9/lib/jira/base_factory.rb:33:in `block (2 levels) in delegate_to_target_class'
    from test.rb:25:in `<main>'

Let me know if there is more data I can provide. The basic http stuff does work, as I can list projects, so I guess it is "issue" specific?

I've tried doing .all and doing a sql query style per the examples, both give the same trace.

solarkennedy commented 10 years ago

Digging into this, the issue is somewhere in: https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/issue.rb#L39

But I don't yet understand how :expand and transitions.fields work.

fertobar commented 10 years ago

Hi, the same issue for me with Ruby 2, Rails 4.

@jira_client.Issue.all NoMethodError: undefined method split' for :expand:Symbol from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/header.rb:172:incapitalize' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/header.rb:165:in block in each_capitalized' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/header.rb:164:ineach' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/header.rb:164:in each_capitalized' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/generic_request.rb:321:inwrite_header' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/generic_request.rb:136:in exec' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1406:inblock in transport_request' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1405:in catch' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1405:intransport_request' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1378:in request' from /var/www/getfable.com/releases/57/vendor/bundle/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:inrequest' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1371:in block in request' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:853:instart' from /home/sessionly/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1369:in request' from /var/www/getfable.com/releases/57/vendor/bundle/ruby/2.1.0/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:inrequest' from /var/www/getfable.com/releases/57/vendor/bundle/ruby/2.1.0/gems/oauth-0.4.7/lib/oauth/consumer.rb:161:in `request' ... 10 levels...

Any suggestion for fix? Thanks!

fertobar commented 10 years ago

Updating :expand Symbol to a String work for me! Like: https://github.com/fertobar/jira-ruby/commit/36369feb1d12f7bcd30d1d157262df68159b6947

Now, I'm getting the Issue list ok!

andrewhavens commented 10 years ago

From what I read of the code, this commit introduced the bug by trying to pass an invalid HTTP header (:expand) to the Client#get method. I'm totally new to this project (and to JIRA), but I'm going to figure out the original author's intention of trying to pass this :expand option.

fertobar commented 10 years ago

sounds good Andrew. I notice http dependency try to apply to the options, the call to split method, but Symbols not respond to split method, so, updating the symbol :expand to a string works for me, because String respond to split method. Also specs works too. I have no permission for commit in the repository :)

andrewhavens commented 10 years ago

I solved the issue and am working on putting together a pull request. The problem was that the url should have been /search?expand=transitions.fields. The other problem was that there didn't seem to be a test for the Issue.all method. I'm working on writing a test for that too.

jackdinh10 commented 9 years ago

I have found that I can do an empty JQL search in the issues to retrieve all the issues if the original way doesn't work.

client.Issue.jql('')