Serverless-offline: Short form http event causes error ("cannot read property 'toUpperCase' of undefined

Created on 20 Sep 2016  路  7Comments  路  Source: dherault/serverless-offline

I tried to run the basic getting started function from the serverles getting started guide

serverless-offline gives me:

~/NRN/src/new_stack$ sls offline start
Serverless: Starting Offline: dev/us-east-1.

Serverless: Routes for hello:

  Type Error ---------------------------------------------

     Cannot read property 'toUpperCase' of undefined

This is from a serverless.yml like this:

 service: aws-nodejs 

 functions:
   hello:
     handler: handler.hello
     events: 
       - http: GET greet

(as per the guide).

When I change it to the longer spec for the http event:

 service: aws-nodejs 

 functions:
   hello:
     handler: handler.hello
     events: 
       - http: 
             path: greet
             method: GET

it works.

Most helpful comment

I looked into this does seem to be because of RC1 representing the different options to describe functions differently in its object model. I will open a ticket with serverless core team to see what if anything they wish to do. Based on that we will take action.

All 7 comments

OK. Thanks for reporting. Will need to adjust for RC1.

I looked into this does seem to be because of RC1 representing the different options to describe functions differently in its object model. I will open a ticket with serverless core team to see what if anything they wish to do. Based on that we will take action.

Have not received a response to this issue from serverless team. Still waiting Issue 2178. If you want to add comments there to facilitate a response it would be appreciated.

Done, thanks.

If you want to get this to work in the meantime you can add this:

if(typeof event.http === 'string'){
  var split = event.http.split(' ');
  event.http = {
    path: split[1],
    method: split[0],
  }
}

Directly after this:

if (!event.http) return;

(line 245 in master right now)

I think we should apply @kajdjakne suggestion for the moment.

Should be fixed in v3.1.0, please confirm :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ozbillwang picture ozbillwang  路  4Comments

JimLynchCodes picture JimLynchCodes  路  4Comments

conradoramalho picture conradoramalho  路  3Comments

stunningpixels picture stunningpixels  路  3Comments

Ali-Dalal picture Ali-Dalal  路  4Comments