examples icon indicating copy to clipboard operation
examples copied to clipboard

Failing with "Parameter 'url' must be a string, not undefined"

Open ritwik-dell opened this issue 6 years ago • 8 comments

Hi, I am new to Serverless and Node.js. I am trying to run the "aws-node-fetch-file-and-store-in-s3" example. I have not modified the code. Here is how I am invoking it.

serverless invoke -f save -l -d "{'image_url':'https://assets-cdn.github.com/images/modules/open_graph/github-mark.png','key':'github.png'}"

I am getting the following error message.

{
    "errorMessage": "Parameter 'url' must be a string, not undefined",
    "errorType": "TypeError",
    "stackTrace": [
        "Url.parse (url.js:90:11)",
        "urlParse (url.js:84:5)",
        "Body.Request (/var/task/node_modules/node-fetch/lib/request.js:27:16)",
        "/var/task/node_modules/node-fetch/index.js:51:17",
        "new Fetch (/var/task/node_modules/node-fetch/index.js:49:9)",
        "Fetch (/var/task/node_modules/node-fetch/index.js:37:10)",
        "module.exports.save.fetch.then.then.response.then.buffer.then (/var/task/handler.
js:9:3)"
    ]
}

I guess I am doing a silly error, but I am not able to get rid of it. Please help.

Thanks in advance.

ritwik-dell avatar Jul 29 '17 01:07 ritwik-dell

Does it work if you use the example command in the README?

https://github.com/serverless/examples/tree/master/aws-node-fetch-file-and-store-in-s3#usage

christophgysin avatar Jul 29 '17 12:07 christophgysin

Nope. I am working on a windows machine. If I use the mentioned command directly I get the following error:

ServerlessError: Serverless command "invoke image_url:" not found

ritwik-dell avatar Jul 29 '17 20:07 ritwik-dell

This seems to be a quoting issue. According to a quick search, the default windows command prompt seems to have weird quoting behaviour. Maybe try powershell instead?

christophgysin avatar Jul 29 '17 20:07 christophgysin

I am also getting the same error : ServerlessError: Serverless command "invoke image_url:" not found

vkanga avatar Jul 29 '17 21:07 vkanga

@christophgysin, I don't think it is a quote issue (I modified the quote to ensure it is working on Windows cmd prompt). I tried Powershell and it is allowing me to use the command as documented in the example.

However, once past the quote issue, I hit the same problem - the error message in my original post. Where is it expecting the parameter 'url'? Why is it 'undefined'? As noted in my original post, I have not modified the code.

ritwik-dell avatar Jul 31 '17 22:07 ritwik-dell

The stacktrace shows you where it fails:

"module.exports.save.fetch.then.then.response.then.buffer.then (/var/task/handler.js:9:3)"

Which is the line:

   fetch(event.image_url)

So it seems that image_url is undefined, hence my assumption that the parameter is not correctly passed due to quoting. You could print the whole event object to the console and check the log to see if the image_url parameter was passed correctly.

christophgysin avatar Aug 02 '17 20:08 christophgysin

I'm having the same issue with undefined as well, maybe a complete noob question but how is the "image_url" supposed to be defined?

jarens7 avatar Sep 27 '18 01:09 jarens7

This is not the same issue. Please double check the example command in the README: https://github.com/serverless/examples/tree/master/aws-node-fetch-file-and-store-in-s3#usage

christophgysin avatar Oct 15 '20 07:10 christophgysin