Miserlou / Zappa

Serverless Python
https://blog.zappa.io/
MIT License
11.89k stars 1.2k forks source link

502 error while deploying #2084

Open tomekbuszewski opened 4 years ago

tomekbuszewski commented 4 years ago

I am getting 502 error while trying to deploy the app.

Context

I have an app written with Django (3.0.4), works great locally. For dev purposes, I use sqlite only. I wanted to deploy it to AWS today, but I am getting 502 errors.

Sorry, I cannot post an app here, since it's private.

Expected Behavior

It should be deployed without problems.

Actual Behavior

Results in 502 error.

Your Environment

Zappa version: 0.51.0 Django version: 3.0.4 Python: 3.7

Zappa config:

{
    "dev": {
        "aws_region": "eu-central-1",
        "django_settings": "hay.hay.settings",
        "profile_name": "default",
        "project_name": "hundred-a-year",
        "runtime": "python3.7",
        "s3_bucket": "hay-dev",
        "slim_handler": false
    }
}

Error on AWS:

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

Results of zappa tail:

[1587228323192] [DEBUG] 2020-04-18T16:45:23.192Z f41f3ef4-dfa2-46dc-95c2-99d6fd9f0852 Zappa Event: {'resource': '/', 'path': '/', 'httpMethod': 'GET', 'headers': {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7,ru;q=0.6,so;q=0.5', 'cache-control': 'max-age=0', 'CloudFront-Forwarded-Proto': 'https', 'CloudFront-Is-Desktop-Viewer': 'true', 'CloudFront-Is-Mobile-Viewer': 'false', 'CloudFront-Is-SmartTV-Viewer': 'false', 'CloudFront-Is-Tablet-Viewer': 'false', 'CloudFront-Viewer-Country': 'PL', 'Host': 'yiudwi21ux.execute-api.eu-central-1.amazonaws.com', 'Referer': 'https://eu-central-1.console.aws.amazon.com/apigateway/home?region=eu-central-1', 'sec-fetch-dest': 'document', 'sec-fetch-mode': 'navigate', 'sec-fetch-site': 'cross-site', 'sec-fetch-user': '?1', 'upgrade-insecure-requests': '1', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', 'Via': '2.0 70d111e01220d4724cfea727fa9dfb91.cloudfront.net (CloudFront)', 'X-Amz-Cf-Id': 'VMUK9rPoyIcqWqOjowgpHrWsI-qW0OTnW1YAUIJ0BZHH-Vr7Z3rWCw==', 'X-Amzn-Trace-Id': 'Root=1-5e9b2ea3-5181626ee6404a71bf9a1db9', 'X-Forwarded-For': '89.64.74.188, 54.239.171.153', 'X-Forwarded-Port': '443', 'X-Forwarded-Proto': 'https'}, 'multiValueHeaders': {'Accept': ['text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'], 'Accept-Encoding': ['gzip, deflate, br'], 'Accept-Language': ['pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7,ru;q=0.6,so;q=0.5'], 'cache-control': ['max-age=0'], 'CloudFront-Forwarded-Proto': ['https'], 'CloudFront-Is-Desktop-Viewer': ['true'], 'CloudFront-Is-Mobile-Viewer': ['false'], 'CloudFront-Is-SmartTV-Viewer': ['false'], 'CloudFront-Is-Tablet-Viewer': ['false'], 'CloudFront-Viewer-Country': ['PL'], 'Host': ['yiudwi21ux.execute-api.eu-central-1.amazonaws.com'], 'Referer': ['https://eu-central-1.console.aws.amazon.com/apigateway/home?region=eu-central-1'], 'sec-fetch-dest': ['document'], 'sec-fetch-mode': ['navigate'], 'sec-fetch-site': ['cross-site'], 'sec-fetch-user': ['?1'], 'upgrade-insecure-requests': ['1'], 'User-Agent': ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'], 'Via': ['2.0 70d111e01220d4724cfea727fa9dfb91.cloudfront.net (CloudFront)'], 'X-Amz-Cf-Id': ['VMUK9rPoyIcqWqOjowgpHrWsI-qW0OTnW1YAUIJ0BZHH-Vr7Z3rWCw=='], 'X-Amzn-Trace-Id': ['Root=1-5e9b2ea3-5181626ee6404a71bf9a1db9'], 'X-Forwarded-For': ['89.64.74.188, 54.239.171.153'], 'X-Forwarded-Port': ['443'], 'X-Forwarded-Proto': ['https']}, 'queryStringParameters': None, 'multiValueQueryStringParameters': None, 'pathParameters': None, 'stageVariables': None, 'requestContext': {'resourceId': '3achqb2vbg', 'resourcePath': '/', 'httpMethod': 'GET', 'extendedRequestId': 'LMQ5gG_WliAFbBw=', 'requestTime': '18/Apr/2020:16:45:23 +0000', 'path': '/dev', 'accountId': '536687225340', 'protocol': 'HTTP/1.1', 'stage': 'dev', 'domainPrefix': 'yiudwi21ux', 'requestTimeEpoch': 1587228323137, 'requestId': 'd3fd55d0-bec3-4424-877b-f6cf00c7affb', 'identity': {'cognitoIdentityPoolId': None, 'accountId': None, 'cognitoIdentityId': None, 'caller': None, 'sourceIp': '89.64.74.188', 'principalOrgId': None, 'accessKey': None, 'cognitoAuthenticationType': None, 'cognitoAuthenticationProvider': None, 'userArn': None, 'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', 'user': None}, 'domainName': 'yiudwi21ux.execute-api.eu-central-1.amazonaws.com', 'apiId': 'yiudwi21ux'}, 'body': None, 'isBase64Encoded': False}
[1587228323192] [DEBUG] 2020-04-18T16:45:23.192Z f41f3ef4-dfa2-46dc-95c2-99d6fd9f0852 host found: [yiudwi21ux.execute-api.eu-central-1.amazonaws.com]
[1587228323192] [DEBUG] 2020-04-18T16:45:23.192Z f41f3ef4-dfa2-46dc-95c2-99d6fd9f0852 amazonaws found in host
[1587228323192] 'NoneType' object is not callable

I've tried various solutions found on the internet, disabling slim_handler, removing pyc files, reinstalling venv. Nothing helped.

bharling commented 4 years ago

same behaviour here

kaedroho commented 4 years ago

I'm getting this error too. Probably related to https://github.com/Miserlou/Zappa/issues/2089

tomekbuszewski commented 4 years ago

My problem was (is, I guess) related to SQLite being "too new" for zappa. This solves it: https://github.com/Miserlou/Zappa/issues/1880#issuecomment-606710104

I know it's pretty dirty, but it's the only solution I found working.