e.g., https://github.com/awslabs/aws-lambda-web-adapter/blob/main/examples/fastapi-response-streaming-zip/app/run.sh#L4 is setting PYTHONPATH to LAMBDA_TASK_ROOT, which led to the search path (more background in Working with .zip file archives for Python Lambda functions) becoming ['', '/var/task', '/var/task', '/var/lang/lib/python38.zip', '/var/lang/lib/python3.8', '/var/lang/lib/python3.8/lib-dynload', '/var/lang/lib/python3.8/site-packages']. The second and third element are duplicate. And even worse, $LAMBDA_RUNTIME_DIR isn't in the search path any more, which led to the user won't be able to use the bundled modules under $LAMBDA_RUNTIME_DIR (e.g., boto3 SDK, which a user may not bundle into their zip archive to stay under the unzipped size limit).
Thanks for reporting this issue. This affects python runtimes below 3.11. From 3.11 and above versions, AWS SDK is installed in /var/lang/lib/python3.x/site-packages.
e.g., https://github.com/awslabs/aws-lambda-web-adapter/blob/main/examples/fastapi-response-streaming-zip/app/run.sh#L4 is setting
PYTHONPATH
toLAMBDA_TASK_ROOT
, which led to the search path (more background in Working with .zip file archives for Python Lambda functions) becoming['', '/var/task', '/var/task', '/var/lang/lib/python38.zip', '/var/lang/lib/python3.8', '/var/lang/lib/python3.8/lib-dynload', '/var/lang/lib/python3.8/site-packages']
. The second and third element are duplicate. And even worse,$LAMBDA_RUNTIME_DIR
isn't in the search path any more, which led to the user won't be able to use the bundled modules under$LAMBDA_RUNTIME_DIR
(e.g., boto3 SDK, which a user may not bundle into their zip archive to stay under the unzipped size limit).