serverless / serverless/examples

aws-python-flask-api - Internal Server Error

Open
#716 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.5k
Forks
4.4k
Avg merge
2h 55m
Merged PRs (30d)
3

Description

aws-python-flask-api example works locally correct but after deploy getting {"message":"Internal Server Error"}

How to reproduce:

npm install
pip install -r requirements.txt
serverless deploy

log:

Using default Python executable: python
Packaging Python WSGI handler...

✔ Service deployed to stack aws-python-flask-api-project-dev (92s)

dashboard: https://app.serverless.com/xxxx/apps/aws-flask-api/aws-python-flask-api-project/
endpoint: ANY - https://xxxx.execute-api.eu-west-1.amazonaws.com
functions:
  api: aws-python-flask-api-project-dev-api (11 MB)

cloudwatch:

2022-09-02T04:37:10.629Z	835dece5-1e3a-50f9-5811-e0c60977e8b1	ERROR	Invoke Error 	{
    "errorType": "Error",
    "errorMessage": "Cannot find module './wsgi_handler.js'\nRequire stack:\n- /var/task/s_api.js\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js",
    "code": "MODULE_NOT_FOUND",
    "requireStack": [
        "/var/task/s_api.js",
        "/var/runtime/UserFunction.js",
        "/var/runtime/Runtime.js",
        "/var/runtime/index.js"
    ],
    "stack": [
        "Error: Cannot find module './wsgi_handler.js'",
        "Require stack:",
        "- /var/task/s_api.js",
        "- /var/runtime/UserFunction.js",
        "- /var/runtime/Runtime.js",
        "- /var/runtime/index.js",
        "    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)",
        "    at Module._require.i.require (/var/task/serverless_sdk/index.js:9:73131)",
        "    at require (internal/modules/cjs/helpers.js:101:18)",
        "    at Object.<anonymous> (/var/task/s_api.js:25:23)",
        "    at Module._compile (internal/modules/cjs/loader.js:1085:14)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
        "    at Module.load (internal/modules/cjs/loader.js:950:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
        "    at Module.require (internal/modules/cjs/loader.js:974:19)",
        "    at require (internal/modules/cjs/helpers.js:101:18)"
    ]
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the aws-python-flask-api example and reproduce the deployment using npm install, pip install -r requirements.txt, and serverless deploy. Inspect the generated s_api.js entry point and the reported wsgi_handler.js module failure in CloudWatch. Done means the deployed API endpoint responds successfully without the Internal Server Error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, flask, python
Domain
api, backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.