Hi, I created a simple workflow with a trigger and a bit of javascript code that returns a string. When I run the code, the string is returned. When i run the entire flow, I get the following error: Error evaluating <my_function_name>: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object.
I don't understand this error, as it's impossible to pass arguments to the javascript code.
Hey Tom,
Could you share the function and what you are passing to it so we can determine what is causing the issue.
Reading the error is pointing to Object being passed and function is expecting a different arg type for the first parameter.
Hey Stefan,
Below you can find the code of the function. I don't know how to access the arguments in a code block of a workflow.
var apikey = literal_string1;
var apisecret = literal_string2;
var nonce = cryptoJs.lib.WordArray.random(20).toString(cryptoJs.enc.Hex);
var timestamp = Date.now();
var signature =
apikey +
"get%2Fv2%2Fmysqldatabases" +
timestamp +
nonce;
var signature = btoa(cryptoJs.HmacSHA256(signature, apisecret));
var authorization =
"hmac " + apikey + ":" + signature + ":" + nonce + ":" + timestamp;
return authorization;
I was able to run this workflow manually and get the same error.
After adding few console.log() I've came to conclusion that btoa() is failing the query.
cryptoJs.HmacSHA256(signature, apisecret) is of Object type and per error it needs to be "string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object"
Not sure of the specifics of this application but if you coerce this object to a string the workflow won't fail.
Hope that helps!
That was indeed the problem. Thank you very much, Stefan!