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

Transition class HTTPError on reading API response #291

Open
kali-hernandez opened this issue Jun 20, 2018 · 1 comment · May be fixed by #292
Open

Transition class HTTPError on reading API response #291

kali-hernandez opened this issue Jun 20, 2018 · 1 comment · May be fixed by #292

Comments

@kali-hernandez
Copy link

When using the Transition class I get an http error while trying to fetch the json from API:

/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:

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)

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.

kali-hernandez pushed a commit to kali-hernandez/jira-ruby that referenced this issue Jun 20, 2018
Fixes sumoheavy#291

Declares `path` for API GET calls using not `issue.self` (which produces full URIs) but `client.options[:rest_base_path]`

Resulting API calls will not have repeated URIs which are raising `request_client.rb:16:in `request': JIRA::HTTPError`

Works For Me (TM)
@kali-hernandez kali-hernandez linked a pull request Jun 20, 2018 that will close this issue
@kali-hernandez
Copy link
Author

Added a PR with a possible solution

kali-hernandez pushed a commit to kali-hernandez/jira-ruby that referenced this issue Jun 20, 2018
Fixes sumoheavy#291

Declares `path` for API GET calls using not `issue.self` (which produces full URIs) but `client.options[:rest_base_path]`

Resulting API calls will not have repeated URIs which are raising `request_client.rb:16:in `request': JIRA::HTTPError`

Works For Me (TM)
kali-hernandez pushed a commit to kali-hernandez/jira-ruby that referenced this issue Jun 21, 2018
Fixes sumoheavy#291

Declares `path` for API GET calls using not `issue.self` (which produces full URIs) but `client.options[:rest_base_path]`

Resulting API calls will not have repeated URIs which are raising `request_client.rb:16:in `request': JIRA::HTTPError`

Works For Me (TM)
kali-hernandez added a commit to kali-hernandez/jira-ruby that referenced this issue Jul 4, 2018
Fixes sumoheavy#291

Declares `path` for API GET calls using not `issue.self` (which produces full URIs) but `client.options[:rest_base_path]`

Resulting API calls will not have repeated URIs which are raising `request_client.rb:16:in `request': JIRA::HTTPError`

Works For Me (TM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant