aws / aws-lambda-python-runtime-interface-client

Apache License 2.0
263 stars 75 forks source link

Regression in handlers supported by bootstrap #43

Closed rli closed 3 years ago

rli commented 3 years ago

For the deployed python3.8 runtime on AWS today, the following Lambda is valid:

Handler: src/hello_world.app.lambda_handler Tree as displayed in Lambda console:

py38test/
  src/
    hello_world/
        __init__.py
        app.py

app.py:

import os
import json

def lambda_handler(event, context):
    # TODO implement
    return {
        'statusCode': 200,
        'body': os.getenv('_HANDLER')
    }

Execution result:

Response
{
  "statusCode": 200,
  "body": "src/hello_world.app.lambda_handler"
}

Function Logs
START RequestId: 1518390e-9e46-43e2-a094-87eac6a55448 Version: $LATEST
END RequestId: 1518390e-9e46-43e2-a094-87eac6a55448
REPORT RequestId: 1518390e-9e46-43e2-a094-87eac6a55448  Duration: 1.01 ms   Billed Duration: 2 ms   Memory Size: 128 MB Max Memory Used: 51 MB  Init Duration: 118.78 ms

However, a local container with the latest awslambdaric fails to run the same lambda:

{"errorMessage": "Unable to import module 'src/hello_world.app': No module named 'src/hello_world'", "errorType": "Runtime.ImportModuleError", "requestId": "33685819-deae-4fb0-aae1-97c81f7aa9e4", "stackTrace": []}

This change in behavior appears to be introduced by https://github.com/aws/aws-lambda-python-runtime-interface-client/commit/620b14824600db3c32ba8e234e3175dbece8b8b5. Is this intended behavior? Since the handler above works on Lambda today, this appears to be customer-breaking.

carlzogh commented 3 years ago

Thanks for the report @rli - This has since been addressed in https://github.com/aws/aws-lambda-python-runtime-interface-client/pull/45 and is going to be released as part of the 1.2.0 version of the awslambdaric package.