'Error message: "'NoneType' object is not callable". - received from zappa deployed django application on AWS Lambda

I'm running into an error after deploying my django app to lambda using zappa.

This is the error:

{'message': 'An uncaught exception happened while servicing this request. You can investigate this with the `zappa tail` command.', 'traceback': ['Traceback (most recent call last):', ' File /var/task/handler.py, line 540, in handler with Response.from_app(self.wsgi_app, environ) as response:', ' File /var/task/werkzeug/wrappers/base_response.py, line 287, in from_app return cls(*_run_wsgi_app(app, environ, buffered))', ' File /var/task/werkzeug/wrappers/base_response.py, line 26, in _run_wsgi_app return _run_wsgi_app(*args)', ' File /var/task/werkzeug/test.py, line 1119, in run_wsgi_app app_rv = app(environ, start_response)', TypeError: 'NoneType' object is not callable]}

These are my zappa settings:

{
  "production": {
    "aws_region": "eu-west-2",
    "django_settings": "app.settings",
    "profile_name": "deployment",
    "project_name": "app",
    "runtime": "python3.6",
    "s3_bucket": "zappa-deployment-uploads",
    "slim_handler": true,
    "exclude": [".ebextensions/", ".elasticbeanstalk/", "webpack/", "app/static/"],
    "vpc_config" : {
    "SubnetIds": [ "..."],
    "SecurityGroupIds": ["..."]
  }
}

I've ensured that my API Gateway hostname has been added to my allowed hosts setting and redeployed.

I've called zappa tail, but it gives me an even shorter error respons "'NoneType' object is not callable".

Can anyone understand why I would be getting this?



Solution 1:[1]

You have an exception being thrown in your code. I have found NoneType is a generic error when using AWS Lambda & Zappa that is masking the true issue.

Some debugging steps:

  1. Ensure your code works locally when you run python manage.py runserver
  2. Output console messages in various places in your code and run zappa tail to identify the section of code that is having troubles
  3. Repeat above option until you have narrowed the location of the problem.

Solution 2:[2]

I was running into a similar issue, tried installing different versions of flask, and discovered it was actually in my zappa configuration file. I had "slim_handler" : "True" and removing this solved the issue for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Edgar
Solution 2 S.B