palashkulsh/jira-cmd

If jira cloud does not support subtasks, shows an error

Closed this issue · 0 comments

I'm working with an older jira cloud project that tracks issues for an open-source project (so maybe isn't getting latest jira software because on a free plan?) Anyway, when I run jira show CORE-1110 I get an error:

/usr/lib/node_modules/cmd-jira/lib/jira/describe.js:75
            {'Subtasks': res.body.fields.subtasks.length},
                                                 ^

TypeError: Cannot read property 'length' of undefined
    at /usr/lib/node_modules/cmd-jira/lib/jira/describe.js:75:50
    at Request.callback (/usr/lib/node_modules/cmd-jira/node_modules/superagent/lib/node/index.js:586:3)
    at Request.<anonymous> (/usr/lib/node_modules/cmd-jira/node_modules/superagent/lib/node/index.js:133:10)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)
    at Stream.<anonymous> (/usr/lib/node_modules/cmd-jira/node_modules/superagent/lib/node/index.js:714:12)
    at emitNone (events.js:72:20)
    at Stream.emit (events.js:166:7)
    at Unzip.<anonymous> (/usr/lib/node_modules/cmd-jira/node_modules/superagent/lib/node/utils.js:120:12)
    at emitNone (events.js:72:20)

I changed line 75 of cmd-jira/lib/jira/decsribe.js to this in my local install:

            {'Subtasks': (res.body.fields.subtasks ? res.body.fields.subtasks.length : "")},

and that fixed it. If I have time later today I'll submit a PR.