Open kali-hernandez opened 6 years ago
When using the Transition class I get an http error while trying to fetch the json from API:
Transition
/Library/Ruby/Gems/2.3.0/gems/jira-ruby-1.5.0/lib/jira/request_client.rb:16:in `request': JIRA::HTTPError
I added some debugging to the request_client.rb and managed to find out a sensible difference in between successful requests:
request_client.rb
get: /rest/api/2/search?jql=[...my_query...] - []
and the unsuccessful one:
get: https://my.host.name/jira/rest/api/2/issue/179217/transitions?expand=transitions.fields - [] /Library/Ruby/Gems/2.3.0/gems/jira-ruby-1.5.0/lib/jira/request_client.rb:16:in `request': JIRA::HTTPError
I suspect the get call under def request() in: https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/client.rb#L226-L229 is erroneously getting the full url rather than the path it expects (e.g. starting from the rest path)
get
def request()
Upon further investigation I found that the Transition class definition in https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/transition.rb#L23 uses #{issue.self} to build the path, whereas most other classes (see: https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/issue.rb#L94 or https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/attachment.rb#L19 or https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/user.rb#L7 just to name a few) use #{client.options[:rest_base_path]} instead.
#{issue.self}
#{client.options[:rest_base_path]}
I have seen at least other 2 places where the url is built with #{issue.self} (https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/watcher.rb#L22 and https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/remotelink.rb#L20). I guess those 2 would produce the same error.
Added a PR with a possible solution
When using the
Transition
class I get an http error while trying to fetch the json from API:I added some debugging to the
request_client.rb
and managed to find out a sensible difference in between successful requests:and the unsuccessful one:
I suspect the
get
call underdef request()
in: https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/client.rb#L226-L229 is erroneously getting the full url rather than the path it expects (e.g. starting from the rest path)Upon further investigation I found that the
Transition
class definition in https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/transition.rb#L23 uses#{issue.self}
to build the path, whereas most other classes (see: https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/issue.rb#L94 or https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/attachment.rb#L19 or https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/user.rb#L7 just to name a few) use#{client.options[:rest_base_path]}
instead.I have seen at least other 2 places where the url is built with
#{issue.self}
(https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/watcher.rb#L22 and https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/resource/remotelink.rb#L20). I guess those 2 would produce the same error.