TransitionIssue and UpdateIssue is not working due to empty responses is not accepted
Critical Issue When I was trying to call .transitionIssue() it sends request and receiving 204 StatusCode (it works successfully), but console throwing error:
[TypeError: Cannot read property 'errorMessages' of undefined]
The issue is the way how compiled line 115 https://github.com/jira-node/node-jira-client/blob/master/src/jira.js#L115
response = _context.sent; if (!(Array.isArray(response.errorMessages) && response.errorMessages.length > 0)) { _context.next = 6; break; } throw new Error(response.errorMessages.join(', '));
We have to accept empty response in case 204 Status Code was returned according to https://docs.atlassian.com/jira/REST/latest/#api/2/issue-doTransition
Temporary solution would be just add string before 115 with:
if (!response) return response;
Please help to address proper resolution
Minor issue
As I can see in legacy plugin there was also handling of status codes:
if (response.statusCode === 400) { callback('Problem with the JQL query'); return; } if (response.statusCode !== 200) { callback(response.statusCode + ': Unable to connect to JIRA during search.'); return; }
Could we please add something similar?
This is simple enough to add a fix to. I was unaware during my re-write that the rest API would ever give an empty response entirely. I'll jump on this quick. I do have a problem with the way the legacy jira package handled errors, so I wouldn't do something like what they did. The rest API itself will usually provide an informative error if there is one with the request you make. Perhaps the best solution is to check the status code of the response, and if it's anything that isn't a 2XX status code, then check for errors.
We do accept pull requests to this repo if you would like to attempt a resolution yourself for future problems. :smile:
I've merged the fix and released it as v1.3.1 for you.
YAY! Works for now. Thank you for fast reaction!