It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Trellinator Error: Command failed Edited

First of all I would like to thank Iaian Dooley for developing Trellinator and making it open source. It really is a game changer when it comes to automating Trello boards and I am very happy to be able to use it for free.

Yesterday I've come across a persistent error when running tests from command line on my local machine:


child_process.js:669
throw err;
^

Error: Command failed: curl --request GET --url 'https://api.trello.com/1/cards/...

This happens whenever I try to retrieve more advanced elements like a list of mentioned members or a new card instance. Here is an example of functions that reliably produce the mentioned error on my side:


function addedCommentToCard(notification)
{
var notif = new Notification(notification);
notif.card().members().each(function(member)
{
card.postComment("I have member: " + member.name());
});
}

function addedCommentToCard(notification)
{
var notif = new Notification(notification);
var card = new Card({link: "https://trello.com/c/zpv2VSM3"});
}

function addedCommentToCard(notification)
{
var notif = new Notification(notification);
var members = notif.mentionedMembers();
}

I must note that I have completed the Hello World tutorial twice with both the PDF and video tutorial and have been using the online documentation since the beginning of working with Trellinator. Unfortunately the tutorial did not cover some of the more advanced queries that are necessary for real workflow automation.

I look forward to some suggestions on how I could go about resolving this and perhaps some insight into why this is happening to begin with as I do not believe I will be able to resolve this issue by myself.

Thank you in advance!
Matthew

1 answer

1 accepted

0 votes
Answer accepted
Iain Dooley Community Leader Aug 26, 2019

@Matthew Cain hey thanks for getting involved!

are you able to please post some additional information (preferably as linked gist files) with the following details:

1) The command line code you're executing to run your tests with your API key/token masked (ie. replace with KEY and TOKEN to indicate where you're including them but don't include the real values)

2) The full source code of the test file you're executing (ie. the source of whatever.run.js that you're executing) with the Trellinator.override_token masked if you've included it (ie. replace the value with XXXXXX to indicate it's present, but don't include the actual token)

3) The full source code of the system under test (ie. Events.js or whatever you've called it that contains your actual functions)

4) The full text of the error above, ie. the entire curl command that's being executed

@Iain DooleyThe following is all the information you have requested. I have included it here in addition to the gist file for future reference and in case the file gets lost. Note that the api key and token have been scrambled instead of masked for better readability.

1. The command syntax I am using is the same you are using in your tutorial:

  • Syntax: node <script_filename> <api-key> <token>
  • Command: node default.run.js cb86334730b2c5a3a63bc297d85a275e 96186dd6cc4d52a2105590ed3651c0947d7f79c01179678fc16001410be95e7e

2. Here is the full content of default.run.js:

const murphy = require("murphytest");
//ADJUST THE PATH TO FIND THE FILES RELATIVE TO YOUR CURRENT DIRECTORY
eval(murphy.load(__dirname,"../../../apps/trellinator/ExecutionQueue.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator/Trellinator.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator/Trigger.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator/TrigTest.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Board.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Card.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Attachment.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/CheckItem.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Checklist.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Comment.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/CustomField.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Exceptions.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/HttpApi.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/IterableCollection.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Label.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/List.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Member.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Notification.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/Team.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/TestConnector.js"));
eval(murphy.load(__dirname,"../../../apps/trellinator-libs/TrelloApi.js"));
//INCLUDE ANY OTHER REQUIRED FILES HERE
eval(murphy.load(__dirname,"../Sample.js"));
eval(murphy.load(__dirname,"notifications/default.run.js/comment_on_card.js"));
//SET SOME MOCKING VARIABLES
TestConnector.test_base_dir = __dirname;
TestConnector.use_sequencer = true;//where multiple URLs need to be cached depending on when they are called
//this is configured by default but not turned on by default
//because otherwise all previously existing tests would need to
//be refixtured
//the override_token needs to be set so that when others run your tests
//the new Trellinator() method doesn't fetch their member
//object instead of using your cached api fixtures
//DO NOT INCLUDE YOUR API KEY HERE -- TOKEN ONLY!!!
Trellinator.override_token = "96186dd6cc4d52a2105590ed3651c0947d7f79c01179678fc16001410be95e7e";
Trellinator.fake_now = new Date("2018-02-28T05:00:00.000Z");
/*OPTIONAL
TestConnector.prefix = "actual";
ExecutionQueue.fake_push = function(name,params,signature,time)
{

}
*/

//TestConnector.nocache = true;//use this to test performance or do setup/teardown
//ADD YOUR TEST FUNCTIONS HERE
addedCommentToCard(comment_on_card);

3. Here is the content of the script being tested (Sample.js):

function addedCommentToCard(notification)
{
  var notif = new Notification(notification);
  var members = notif.mentionedMembers();
}


4. Here is the full stack trace dump:

child_process.js:669
throw err;
^

Error: Command failed: curl --request GET --url 'https://api.trello.com/1/boards /5d6445da6e1af0201ec55b26/members?fields=fullName,username&key=cb86334730b2c5a3a63bc297d85a275e&token=96186dd6cc4d52a2105590ed3651c0947d7f79c01179678fc16001410be95e7e'

at checkExecSyncError (child_process.js:629:11)
at Object.execSync (child_process.js:666:13)
at TestConnector.fetch (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:22:1), <anonym ous>:87:29)
at Function.HttpApi.call (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:15:1), <anon ymous>:89:24)
at Function.TrelloApi.get (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:23:1), <ano nymous>:80:20)
at Board.members (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:7:1), <anonymous>:24 1:66)
at Notification.membersMentionedInComment (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.ru n.js:20:1), <anonymous>:1215:22)
at Notification.mentionedMembers (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:20:1 ), <anonymous>:659:21)
at addedCommentToCard (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:25:1), <anonymo us>:4:23)
at Object.<anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\s ample_board\Sample.js.murphy\default.run.js:49:1)
Iain Dooley Community Leader Aug 27, 2019

@Matthew Cain Okay thanks, this is indeed very odd.

If you look at the command here:

https://gist.github.com/yooksi/75d8ade50021f3a1178025b496f4c8dd#file-stack_trace_dump-txt

You can see that there is a space in between "boards" and the "/" following it.

That URL is generated here:

https://www.theprocedurepeople.com/trellinator-automate-trello/docs/trellinator-libs_Board.js.html#line237

You can see that there's no space there. The URL is passed into either UrlFetch if present, or the TestConnector if not, on this line:

https://www.theprocedurepeople.com/trellinator-automate-trello/docs/trellinator-libs_HttpApi.js.html#line88

So if you can't replicate this error in Google Apps Script rather than on the command line, that means that there is some point in the TestConnector.fetch method at which a space is being inserted into that command :S

Can you try putting:

console.log(url);

in between lines 88 and 89 of HttpApi.js and:

console.log(live_url);

in between lines 27 and 28 of TestConnector.js and then see if that space is present in the URL?

Then maybe:

console.log(cmd);

before line 87 of TestConnector.js

It seems to defy logic that space could be present because the only thing done to the url argument passed into TestConnector.fetch is the replace call on line 27.

It could be some sort of weird width limit configured in your terminal that's being applied to the command when passed into Node or something. Let me know what you get out of those commands.

My apologies, I have made a mistake while formatting the dump for improved readability. That whitespace is not present in the original stack trace. Here is the original non-edited stack trace as it appears in my bash console (with scrambled key/token):

child_process.js:669
throw err;
^

Error: Command failed: curl --request GET --url 'https://api.trello.com/1/boards
/5d6445da6e1af0201ec55b26/members?fields=fullName,username&key=cb86334730b2c5a3a
63bc297d85a275e&token=96186dd6cc4d52a2105590ed3651c0947d7f79c01179678fc16001410b
e95e7e'
at checkExecSyncError (child_process.js:629:11)
at Object.execSync (child_process.js:666:13)
at TestConnector.fetch (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub
\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:22:1), <anonym
ous>:87:29)
at Function.HttpApi.call (eval at <anonymous> (C:\Users\Yooks\Documents\GitH
ub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:15:1), <anon
ymous>:89:24)
at Function.TrelloApi.get (eval at <anonymous> (C:\Users\Yooks\Documents\Git
Hub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:23:1), <ano
nymous>:80:20)
at Board.members (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\gerty
-trello\boards\sample_board\Sample.js.murphy\default.run.js:7:1), <anonymous>:24
1:66)
at Notification.membersMentionedInComment (eval at <anonymous> (C:\Users\Yoo
ks\Documents\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.ru
n.js:20:1), <anonymous>:1215:22)
at Notification.mentionedMembers (eval at <anonymous> (C:\Users\Yooks\Docume
nts\GitHub\gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:20:1
), <anonymous>:659:21)
at addedCommentToCard (eval at <anonymous> (C:\Users\Yooks\Documents\GitHub\
gerty-trello\boards\sample_board\Sample.js.murphy\default.run.js:25:1), <anonymo
us>:4:23)
at Object.<anonymous> (C:\Users\Yooks\Documents\GitHub\gerty-trello\boards\s
ample_board\Sample.js.murphy\default.run.js:49:1)
Iain Dooley Community Leader Aug 27, 2019

@Matthew Cain ah okay :)

That's good because I was starting to question reality for a second.

So what happens if you take that exact curl command and execute it on the command line?

@Iain Dooley You can also find the raw stack trace on gist. In any case this error happens only when requesting certain information and is not at all a random thing. It either might be system related (I am on Windows) or is connected with insufficient privileges given to the bot, although I don't think that's likely.

@Iain DooleyWhen I execute the curl command directly in command line I get the following output:

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 148 100 148 0 0 407 0 --:--:-- --:--:-- --:--:-- 406[{"id":"5d4d38d41c73565415527279","fullName":"Gerty","username":"gertyb"},{"id":"54517baf8adff5e683d9caae","fullName":"Matthew","username":"yooks"}]

Although I can't understand what it means. Perhaps setting up a shared board where we could try executing the exact same code on the same card would be useful in resolving this issue? Let me know what you think.

Iain Dooley Community Leader Aug 27, 2019

@Matthew Cain you should get a clearer error if you execute the curl command directly. Do you mean that you're running it under cygwin on windows?

Iain Dooley Community Leader Aug 27, 2019

@Matthew Cain okay, I posted prior to seeing your comment above, so apologies for the non sequiter :)

That output looks as though the command is executing succesfully. The response you're seeing is the valid JSON that you'd expect.

So this isn't an issue of access or a problem with the command, this is an issue with Node executing that command somehow.

Are you able to produce a node.js file that will execute that curl command at all? It might be a problem with execSync versus exec or something on that particular version of node?!?!

I don't really know enough about node to tell. I basically learned Node in order to create the command line execution for Trellinator so I'm a bit of a n00b :)

Iain Dooley Community Leader Aug 27, 2019

@Matthew Cain for reference I'm running node 

v8.11.2

Are you able to produce a node.js file that will execute that curl command at all?

@Iain Dooley Could you elaborate on what you meant with this? I know next to nothing about node, just enough to install packages and setup basic things. I am also very new to JavaScript in general but I come from a stronger Java background so I am adapting fast.

I am running node version v10.16.2.

Do you think I should downgrade node and try the command again?

@Iain Dooley It might be important to note that I am running this through MINGW64 bash console that comes with the default installation of Git for Windows.

Another thing I could do is try running Trellinator tests on Xubuntu (VM) and see what happens. Sorry that this is turning out to be a bit of a hassle, I often end up with these kind of issues so I am use to it but I do not wish to take too much of your time that would be better spend developing the system rather then helping me debug it.

Iain Dooley Community Leader Aug 27, 2019

@Matthew Cain If you look at lines 85 and 87 of TestConnector.js you can see where the curl command is constructed and then executed using the execSync command.

For example here's a tutorial on how to do this:

https://dzone.com/articles/execute-unix-command-nodejs

Are you able to produce a simple node script that will execute that command if you just hard code it into the script?

What I want to do is narrow down whether or not this is a problem with the execution of that command from Node, because it appears as though the command is running perfectly correctly when you execute it directly from the command line.

If you produce that script, and it has the same error, then you can add the user iaindooley to the board on which you're fetching members, and post the script here, and I can attempt to run exactly the same script from my machine to confirm that it's a platform issue.

Iain Dooley Community Leader Aug 27, 2019

@Matthew Cain If you have access to a linux VM then you could try the same simple script there. I'd say that this bash implementation is the most likely culprit rather than the node version, I don't think exec commands change very frequently ... 

Iain Dooley Community Leader Aug 27, 2019

@Matthew Cain there's also definitely a way to do that API post without executing it from the command line but it's beyond my ken. Hopefully someone better at Node comes along and updates it :)

@Iain DooleyI've managed to successfully execute this node script:

var sys = require('util')
var exec = require('child_process').exec;

var cmd = "curl --request GET --url \"https://api.trello.com/1/boards/5d6445da6e1af0201ec55b26/members?fields=fullName,username&key=cb86334730b2c5a3a63bc297d85a275&token=96186dd6cc4d52a2105590ed3651c0947d7f79c01179678fc16001410be95e7e\""

var child = exec(cmd, function (error, stdout, stderr) {

  console.log('stdout: ' + stdout);
  console.log('stderr: ' + stderr);

  if (error !== null) {
    console.log('exec error: ' + error);
}
});

It was not working at first but then I replaced double quotes with single ones and no error was thrown. Perhaps this is the case in the original issue? I know that quite often single quotation marks need to be replaced with double ones in order to work on Windows platforms. In any case the script above executes without throwing errors from git bash console.

I will try to run the same on Xubuntu VM and report my findings.

Iain Dooley Community Leader Aug 29, 2019

@Matthew Cain okay nice! If you're able to work out how the quoting should work in the TestConnector.js file such that it uses double quotes just send me a pull request and I'll test it out and commit to the main repo. 

@Iain Dooley Thank you for the opportunity to make a direct contribution to your project. I have resolved the issue and submitted both a report and a pull request to iaindooley/trellinator-libs repository.

I would like to stay in further contact, is there a more direct way to contact you?

Perhaps via email or some form of chat channel.

Iain Dooley Community Leader Sep 10, 2019

@Matthew Cain You can always ping me via the Trellinator public Trello board or email iain@benkoboard.com :)

Like Matthew Cain likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Trello

Develop a new Habit during Lockdown

If you had to thrive a new habit during a lockdown, what would it be? Trello

1,520 views 13 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you