Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better error message for the user's failure to run `pip freeze #1312

Open
simsong opened this issue Mar 28, 2024 · 0 comments
Open

Comments

@simsong
Copy link

simsong commented Mar 28, 2024

Context

Currently, adding packages to the Python virtual environment but failing to run pip freeze results in inscrutable errors when the zappa package is deployed to lambda.

Expected Behavior

It would be great if we could have a more sensible error.

Actual Behavior

Here is an example:

[1711493743565] INIT_START Runtime Version: python:3.11.v30 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:2d26a57600db1f6cf7cc34a4f11185001f7bae5ca901b445c13723efea1130a6
[1711493744387] Instancing..
[1711493744449] [INFO] 2024-03-26T22:55:44.448Z 1d3e5b21-f04c-4567-9940-3e2fa7f3aacd Found credentials in environment variables.
[1711493760944] LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
[1711493760944] [ERROR] SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers (__init__.py, line 1681)
Traceback (most recent call last):
  File "/var/task/handler.py", line 657, in lambda_handler
    return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 241, in lambda_handler
    handler = global_handler or cls()
  File "/var/task/handler.py", line 138, in __init__
    self.app_module = importlib.import_module(self.settings.APP_MODULE)
  File "/var/lang/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/tmp/planttracer-/bottle_app.py", line 59, in <module>
    import wsgiserver     # pylint: disable=syntax-error

Possible Fix

Option 1 - Run pip freeze and automatically update requirements.txt as part of zappa update or zappa deploy.
Option 2 - Run pip freeze to a different location and generate an error if the two files do not agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant