question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deploying Python serverless app fails with nonsensical/incomplete error message

See original GitHub issue

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:
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:BatchGetItem
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
        - dynamodb:DescribeTable
        - dynamodb:CreateTable
        - dynamodb:GetRecords
      Resource:
        - { "Fn::GetAtt": ["DynamoTable", "Arn"] }
    - Effect: Allow
      Action:
        - sns:Publish
      Resource: ${self:custom.topicArn}
  environment:
    NS_AWS_REGION: '${self:provider.region}'
    NS_TOPIC_ARN:
      Ref: NSChannel
    NS_ACCESS_KEY_ID: REDACTED
    NS_SECRET_ACCESS_KEY: REDACTED

plugins:
  - serverless-python-requirements
  - serverless-wsgi
  - serverless-domain-manager

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:
      - ''
      - - 'arn:aws:sns:'
        - Ref: AWS::Region
        - ":"
        - Ref: AWS::AccountId
        - ":"
        - Fn::GetAtt:
          - NSChannel
          - TopicName

  
functions:
  app:
    handler: wsgi_handler.handler
    events:
      - http: ANY /
      - http: 'ANY {proxy+}'
  probeUrls:
    handler: main.check_all
    events:
      - schedule:
          rate: cron(*/5 * * * ? *)
          enabled: true

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 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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mfsjrcommented, Feb 13, 2020

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

1reaction
medikoocommented, Feb 13, 2020

@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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 10 Serverless Deployment Errors (and How to Fix Them)
The most common error I see our users encounter is when a deploy fails because a previous deploy was unsuccessful. · This situation...
Read more >
Error deploying Python package to AWS lambda using ...
This is an open issue as on date 10th March 2022. The serverless plugin rewrites the file into .serverless directory & it assumes...
Read more >
How do I handle errors in serverless applications? - AWS
In this tutorial, you will design and run a serverless workflow using AWS Step Functions that will gracefully handle these errors. You'll create...
Read more >
Python SDK - Serverless Framework
This will cause the invocation to still display as an error in the serverless ... To alleviate this issue, when deploying a Flask...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found