jira-ruby: JIRA::HTTPError: JIRA::HTTPError

We have some scripts which we use for creating tasks in jira. But for couple of days i am getting following error

JIRA::HTTPError: JIRA::HTTPError from /var/lib/gems/2.3.0/gems/jira-ruby-1.6.0/lib/jira/request_client.rb:15:in request' from /var/lib/gems/2.3.0/gems/jira-ruby-1.6.0/lib/jira/client.rb:238:in request’ from /var/lib/gems/2.3.0/gems/jira-ruby-1.6.0/lib/jira/client.rb:216:in get' from /var/lib/gems/2.3.0/gems/jira-ruby-1.6.0/lib/jira/base.rb:95:in all’ from /var/lib/gems/2.3.0/gems/jira-ruby-1.6.0/lib/jira/base_factory.rb:31:in block (2 levels) in delegate_to_target_class' from (irb):18 from /usr/bin/irb:11:in <main>’

Earlier i was using v1.4.3 but issue still persist after updating to v1.6.0. I think it might be due to some changes in jira apis. ({ username: JiraAuth::USERNAME, password: JiraAuth::PASSWORD, site: JiraAuth::SITE, context_path: ‘’, auth_type: :basic } these are the parameters used for client.)

About this issue

Most upvoted comments

Looks like it works once I switched from passing JIRA our username to our email address.

username: ‘robby@planetargon.com’ works whereas username: ‘robbyrussell’ no longer worked

@zhangyonguu you’re saying that JIRA’s API doesn’t return messages on its API error responses? I’d have to look into that but it seems hard to believe. Maybe it returns a custom error and the descriptive message isn’t where you’re expecting it to be? In any case returning JIRA::HTTPError: JIRA::HTTPError isn’t helpful nor do I believe it’s what is intended.

I think the bigger issue here is the obfuscation of the real error. JIRA::HTTPError: JIRA::HTTPError should be JIRA::HTTPError: descriptive error message but because he’s overriding StandardError’s message attribute its printing the name of the error class twice. It’s definitely a bug.

Something like this would fix it.

require 'forwardable'
module JIRA
  class HTTPError < StandardError
    extend Forwardable

    def_instance_delegators :@response, :code
    attr_reader :response, :my_message

    def initialize(response)
      @response = response
      @my_message = response.try(:message) || response.try(:body)
      super @my_message
    end
  end
end