serverless / serverless

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.
https://serverless.com
MIT License
46.51k stars 5.72k forks source link

Deploying Python serverless app fails with nonsensical/incomplete error message #7084

Open skytreader opened 4 years ago

skytreader commented 4 years ago

Bug Report

Description

  1. What did you do? Deployed a serverless app written in Python.
  2. What happened? Deployment failed, the only exception being
 Exception -----------------------------------------------

  <Buffer 54 72 61 63 65 62 61 63 6b 20 28 6d 6f 73 74 20 72 65 63 65 6e 74 20 63 61 6c 6c 20 6c 61 73 74 29 3a 0a 20 20 46 69 6c 65 20 22 2f 68 6f 6d 65 2f 63 ... >

  Get Support --------------------------------------------
  1. What should've happened? I expect a readable and complete exception message as to what failed.
  2. What's the content of your serverless.yml file?
    
    service: name

provider: name: aws runtime: python3.6 stage: ${opt:stage, 'dev'} region: eu-west-1 timeout: 30 iamRoleStatements:

plugins:

custom: tableName: 'ns-${self:provider.stage}' topicName: 'ns-${self:provider.stage}' domainEnvSuffix: dev: -dev prod: '' customDomain: domainName: ${self:service}${self:custom.domainEnvSuffix.${self:provider.stage}}.example.com certificateName: '*.example.com' stage: ${self:provider.stage} createRoute53Record: true endpointType: edge wsgi: app: main.app packRequirements: true pythonRequirements: dockerizePip: non-linux topicArn: Fn::Join:

functions: app: handler: wsgi_handler.handler events:

resources: Resources: DynamoTable: Type: 'AWS::DynamoDB::Table' Properties: ...REDACTED... NSChannel: Type: "AWS::SNS::Topic" Properties: TopicName: ${self:custom.topicName}

1. What's the output you get when you use the `SLS_DEBUG=*` environment variable (e.g. `SLS_DEBUG=* serverless deploy`)

```Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command requirements
Serverless: Load command requirements:clean
Serverless: Load command requirements:install
Serverless: Load command requirements:cleanCache
Serverless: Load command wsgi
Serverless: Load command wsgi:serve
Serverless: Load command wsgi:install
Serverless: Load command wsgi:clean
Serverless: Load command wsgi:command
Serverless: Load command wsgi:command:local
Serverless: Load command wsgi:exec
Serverless: Load command wsgi:exec:local
Serverless: Load command wsgi:manage
Serverless: Load command wsgi:manage:local
Serverless: Load command wsgi:flask
Serverless: Load command wsgi:flask:local
Serverless: Load command create_domain
Serverless: Load command delete_domain
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Generated requirements from requirements.txt in /serverless/requirements.txt...
Serverless: Installing requirements from .serverless/requirements/requirements.txt ...
Serverless: Running ...
Serverless: Using Python specified in "runtime": python3.6
Serverless: Packaging Python WSGI handler...
Serverless: Packaging required Python packages...

 Exception -----------------------------------------------

  <Buffer 54 72 61 63 65 62 61 63 6b 20 28 6d 6f 73 74 20 72 65 63 65 6e 74 20 63 61 6c 6c 20 6c 61 73 74 29 3a 0a 20 20 46 69 6c 65 20 22 2f 68 6f 6d 65 2f 63 ... >

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              10.16.3
     Framework Version:         1.59.3
     Plugin Version:            3.2.5
     SDK Version:               2.2.1
     Components Core Version:   1.1.2
     Components CLI Version:    1.4.0

If you translate the hexdump in the buffer object, you will see that it is the beginnings of a Python stack trace:

Traceback (most recent call last):
  File "/home/c
medikoo commented 4 years ago

@skytreader thanks for report. Still it looks as an issue in some plugin you rely on, which instead of throwing JavaScript error instance, throws a Node.js buffer instance

Buffer can be anything, technically a binary data, which doesn't translate meaningfully to utf8 string, that's why it's displayed like that.

Ideally if you can narrow the issue, coin which plugin is responsible for that, and open an issue at its repository

mfsjr commented 4 years ago

I'm getting a similar error, the reported exception is: <Buffer > Results of logging are very similar to those reported above.

My plugins are:

Tried first with current serverless version, 1.60.4

 Operating System:          darwin
 Node Version:              12.14.0
 Framework Version:         1.54.0
 Plugin Version:            3.2.6
 SDK Version:               2.2.1
 Components Core Version:   1.1.2
 Components CLI Version:    1.4.0

Also using Python 3.6

mfsjr commented 4 years ago

I commented out serverless-wsgi from my serverless.yaml and the deploy ran successfully a number of times, no failures since then.

Note that the crashes described above will leave a wsgi_handler and serverless_wsgi file in your project root.

I found if I kept these files in my project, not only would the deploy succeed, but the deployment would work as expected.

medikoo commented 4 years ago

@mfsjr this should be reported to project which propagates buffer as an exception. In my understanding it's one of the plugins that you rely on, and not the Framework (Framework just surfaces the error that came out from a plugin, as it is)

mfsjr commented 4 years ago

@medikoo your understanding is correct, and it was reported here: https://github.com/logandk/serverless-wsgi/issues/122

Charon922 commented 4 years ago

I have the same issue. `Exception -----------------------------------------------

<Buffer 57 41 52 4e 49 4e 47 3a 20 54 68 65 20 64 69 72 65 63 74 6f 72 79 20 27 2f 2e 63 61 63 68 65 2f 70 69 70 27 20 6f 72 20 69 74 73 20 70 61 72 65 6e 74 ... 1188 more bytes>`

Translate it to text is : WARNING: The directory '/.cache/pip' or its parent