Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError When Invoking Python (serverless v5.5.0) #723

Closed
paulcruseSG opened this issue Jul 1, 2019 · 9 comments
Closed

TypeError When Invoking Python (serverless v5.5.0) #723

paulcruseSG opened this issue Jul 1, 2019 · 9 comments
Labels

Comments

@paulcruseSG
Copy link

Trying to invoke a python lambda function, get this error:

/Users/paulcruse/Developer/code/deploy-integration-tests/node_modules/serverless-offline/src/index.js:928
                  response.statusCode = statusCode = result.statusCode || 200;

TypeError: Cannot read property 'statusCode' of null
    at createLambdaContext (/Users/paulcruse/Developer/code/deploy-integration-tests/node_modules/serverless-offline/src/index.js:928:61)
    at Object.fail (/Users/paulcruse/Developer/code/deploy-integration-tests/node_modules/serverless-offline/src/createLambdaContext.js:21:18)
    at ChildProcess.process.on.code (/Users/paulcruse/Developer/code/deploy-integration-tests/node_modules/serverless-offline/src/functionHelper.js:71:19)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:557:12)

This my yaml file set-up:

plugins:
    - serverless-plugin-bind-deployment-id
    - serverless-python-requirements
    - serverless-sqs-local
    - serverless-dynamodb-local
    - serverless-offline
custom:
    serverless-offline:
        port: 9000
        prefix: ${self:custom.base_path}
        stage: local
        region: us-east-1
        noAuth: true
@paulcruseSG paulcruseSG changed the title TypeError When Invoking Python TypeError When Invoking Python (serverless v5.5.0) Jul 1, 2019
@dherault
Copy link
Owner

dherault commented Jul 2, 2019

Hello @paulcruseSG
You're not the first to have this issue: #722
What does your lambda looks like ? I'm fixing this in the next version I'm tired of this bug.

@dherault
Copy link
Owner

dherault commented Jul 2, 2019

Fixed in v5.5.1

@paulcruseSG
Copy link
Author

paulcruseSG commented Jul 2, 2019

@dherault This is a python based lambda using a function decorator:

This is the file being invoked:

@apigateway_handler()
def handle(client):
    client.response_body = hello_word(client.request_body)

This is the decorator code:

def apigateway_handler(**kwargs):
    def decorator_func(func):
        def wrapper(event, context):
            client = ApiGatewayFramework(event, **kwargs)
            if client.validate_request_and_permissions(**kwargs):
                func(client)
            return client.response
        return wrapper
    return decorator_func

And this is what client.response spits out:

@property
def response(self):
    return {
        'headers': self.response_headers,
        'statusCode': self.response_code, # response_code defaults to 200 when not explicitly set
        'body': self.response_body
    }

But thanks for working on a fix so fast...

@dnalborczyk
Copy link
Collaborator

@paulcruseSG did v5.5.1 fix your issue?

@dherault
Copy link
Owner

dherault commented Jul 4, 2019

I think not

@dnalborczyk
Copy link
Collaborator

@paulcruseSG I just reverted a commit which broke the functionality. should be fixed with the next release. (note: there still seems to be a timeout issue.)

from npm: I fairly safe version to use should be v5.4.2 (until master is released)

@dherault
Copy link
Owner

dherault commented Jul 6, 2019

v5.6.1

@paulcruseSG
Copy link
Author

@dherault @dnalborczyk Thanks for the quick response and fix; was away for July 4th and come back to see a fix. Will give this a look later today, but either way thanks for the fix

@sumeetweb
Copy link

Installing python-dev package fixed this for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants