We accidentally started passing nil to client.Project.find, in other words we did something like:
client.Project.find(nil)
The error message that we got made it quite difficult to debug the issue:
TypeError: no implicit conversion of Array into Hash
from jira/base.rb:399:in `merge!'
from jira/base.rb:399:in `set_attrs'
from jira/base.rb:388:in `set_attrs_from_response'
from jira/base.rb:340:in `fetch'
from jira/base.rb:110:in `find'
from jira/base_factory.rb:33:in `block (2 levels) in delegate_to_target_class'
from app/models/project_services/jira_service.rb:56:in `block in jira_project'
from app/models/project_services/jira_service.rb:304:in `jira_request'
from app/models/project_services/jira_service.rb:56:in `jira_project'
It happens because when key passed to JIRA::Base.find is nil or empty string the constructed URL is /rest/api/2/project or "/rest/api/2/project/" respectively. In this case JIRA API response is an array of projects instead of a hash. This causes TypeError: no implicit conversion of Array into Hash exception in JIRA::Base#set_attrs.
My proposal is to add a check that key is not nil and not an empty string. Would you accept a patch that does that?
Thank you for creating this gem!
We accidentally started passing
nil
toclient.Project.find
, in other words we did something like:The error message that we got made it quite difficult to debug the issue:
It happens because when
key
passed toJIRA::Base.find
isnil
or empty string the constructed URL is/rest/api/2/project
or"/rest/api/2/project/"
respectively. In this case JIRA API response is an array of projects instead of a hash. This causesTypeError: no implicit conversion of Array into Hash
exception inJIRA::Base#set_attrs
.My proposal is to add a check that
key
is notnil
and not an empty string. Would you accept a patch that does that?