Jira-issue-field-demo returning undefined is not a valid argument

I have been learning to use the ACE framework and used the jira-issue-field demo as a start. The issue I have run into and has me scratching my head is that when I go to call any Rest Api I get:

Unhandled error: TypeError: undefined is not a valid argument for URI
_ at new URI (D:\projects\Atlassian\CostCodeUpdater\node_modules\urijs\src\URI.js:54:15)_
_ at HostClient.modifyArgs (D:\projects\Atlassian\CostCodeUpdater\node_modules\atlassian-connect-express\lib\internal\host-request.js:85:21)_
_ at D:\projects\Atlassian\CostCodeUpdater\node_modules\atlassian-connect-express\lib\internal\host-request.js:201:33_
_ at lib$rsvp$$internal$$tryCatch (D:\projects\Atlassian\CostCodeUpdater\node_modules\rsvp\dist\rsvp.js:1036:16)_
_ at lib$rsvp$$internal$$invokeCallback (D:\projects\Atlassian\CostCodeUpdater\node_modules\rsvp\dist\rsvp.js:1048:17)_
_ at lib$rsvp$$internal$$publish (D:\projects\Atlassian\CostCodeUpdater\node_modules\rsvp\dist\rsvp.js:1019:11)_
_ at lib$rsvp$asap$$flush (D:\projects\Atlassian\CostCodeUpdater\node_modules\rsvp\dist\rsvp.js:1198:9)_
_ at nextTickCallbackWith0Args (node.js:420:9)_
_ at process.tickCallback (node.js:349:13)

which in the demo uses the following code:

var promisify = function(object, method) {
        return function () {
            var args = Array.from(arguments);
            return new Promise(function(resolve, reject) {
                var callback = function(err, resp, body) {
                    if (err || resp.statusCode < 200 || resp.statusCode >= 300) {
                        reject(err || body);
                    }
                    resolve(body, resp);
                };
                object[method].apply(object, [args, callback]);
            });
        }
    };

    var getTeamsFromJIRA = function(req) {
        return promisify(addon.httpClient(req),"get")({url: teamFieldUrl})
            .then(function(body) {
                console.log('returning teams from JIRA');
                return JSON.parse(body).values;
        });
    };

Now I have followed the code through an the error appears to be related to when the arguments(options) are passed to the host-request.js and it should be object members but seems to be an array instead which means the options variable which contains {url: ‘/rest/api/2/field/teams-add-on__team-issue-field/option’ } cannot be called using options.url as this results in undefined. If I hard code the string it will work.

I am fairly new to some of these concepts so any insight or assistance would be very much appreciated.

Thanks you in Advance

Hi, is the error a result of a user action when interacting with the add-on or have you tried to modify the demo in any way to call a different endpoint?

I appreciate your quick response. I have not modified the demo and it is when you click the Teams in Project item in Project Settings. Sorry I posted the error from my modified addon but the Teams Add on has the exact same error and when I console.log throughout to debug I can see it is having the same issue. options.url returns undefined. To reproduce I download from the bit bucket, extract into a folder named Teams, change the config.json localbaseurl to my ngrok url, deploy to Jira and everything related to storing and retrieve from addon store works but the Jira rest stuff doesn’t. If I post the commands using curl or something or hardcode a string then it works.

Unhandled error: TypeError: undefined is not a valid argument for URI
at new URI (D:\projects\Atlassian\Teams\node_modules\urijs\src\URI.js:54:15)
at HostClient.modifyArgs (D:\projects\Atlassian\Teams\node_modules\atlassian-connect-express\lib\internal\host-request.js:75:21)
at D:\projects\Atlassian\Teams\node_modules\atlassian-connect-express\lib\internal\host-request.js:191:33
at lib$rsvp$$internal$$tryCatch (D:\projects\Atlassian\Teams\node_modules\rsvp\dist\rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (D:\projects\Atlassian\Teams\node_modules\rsvp\dist\rsvp.js:1048:17)
at lib$rsvp$$internal$$publish (D:\projects\Atlassian\Teams\node_modules\rsvp\dist\rsvp.js:1019:11)
at lib$rsvp$asap$$flush (D:\projects\Atlassian\Teams\node_modules\rsvp\dist\rsvp.js:1198:9)
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)

Is it possible that it is some dependency version issue or something?

This is possible, which node version are you using? It works fine for me and I’m at 5.1.0.

I have switched to node 5.1.0 and still have the same error. Could it be a dependency version?

This is my base level list:

npm list --depth=0
my-addon@0.0.1 D:\projects\Atlassian\teams
├── atlassian-connect-express@2.0.0
├── body-parser@1.17.1
├── compression@1.6.2
├── cookie-parser@1.4.3
├── errorhandler@1.5.0
├── express@4.15.2
├── express-hbs@1.0.4
├── jugglingdb-sqlite3@0.0.5
├── morgan@1.8.1
├── nedb@1.8.0
├── static-expiry@0.0.11
└── underscore@1.8.3

Anyone else able to reproduce this?

Hi @carl.kitching I have the same npm dependencies set and the add-on works fine for me (adding / removing team members, associating them to project, filling the field values in create issue). I did remember fixing a similar bug back in 1 Feb 2017 (see this commit). Just double checking you’re on the latest master?

Also I am on OSX I wonder if this problem is OS related.

I am running the latest master and it has all the changes in that commit. I am running on windows 10 if that makes a difference.I am really pulling my hair out with this one. To me it seems like the object array is not being passed or read as an object array thus options.url returns udnefined. If I just set the string then it works but this is not really a workaround in this case.