Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix lambda layer version compatibility with Python 3.11 #9020

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

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

alexrashed
Copy link
Member

Motivation

This PR fixes an issue where Lambda layer compatibility check failed for the python3.11 runtime:

$ awslocal lambda publish-layer-version --layer-name layer1 --zip-file fileb://.serverless/MyLayer.zip --compatible-runtimes python3.11

An error occurred (ValidationException) when calling the PublishLayerVersion operation: 1 validation error detected: Value '[python3.11]' at 'compatibleRuntimes' failed to satisfy constraint: Member must satisfy enum value set: [java17, provided, nodejs16.x, nodejs14.x, ruby2.7, python3.10, java11, python3.11, dotnet6, go1.x, nodejs18.x, provided.al2, java8, java8.al2, ruby3.2, python3.7, python3.8, python3.9]

Changes

This PR adds python3.11 to the list of supported runtimes for Lambda layer validation.

Testing

A snapshot verified test creating a Lambda layer with all possible validations.
However, this test does not save us from the same mistake happening again, because it uses the list of RUNTIMES which is used by the validation.
Initially, I wanted to use the keys of the IMAGE_MAPPING dict (which is described as the dict where newly supported runtimes should be added), but this mapping is contained in lambda_models (even though I think it's not a model).
We could move this mapping from there and directly use it for the runtime validation, then this issue could not happen in the future again. Happy for any feedback!

@alexrashed alexrashed added the semver: patch Non-breaking changes which can be included in patch releases label Aug 30, 2023
@alexrashed alexrashed added this to the 2.3 milestone Aug 30, 2023
@alexrashed alexrashed self-assigned this Aug 30, 2023
@coveralls
Copy link

coveralls commented Aug 30, 2023

Coverage Status

coverage: 80.355% (-0.02%) from 80.37% when pulling 5b13a04 on fix-lambda-layer-compatibility-py311 into 5b16d3b on master.

@github-actions
Copy link

github-actions bot commented Aug 30, 2023

LocalStack Community integration with Pro

       2 files         2 suites   1h 22m 52s ⏱️
2 150 tests 1 676 ✔️ 474 💤 0
2 151 runs  1 676 ✔️ 475 💤 0

Results for commit 5b13a04.

♻️ This comment has been updated with latest results.

Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, refactoring, and clarifying comments 👍

nit: Adding a comment pointing to the IMAGE_MAPPING (and/or vice-versa) would help to catch this update chore the next time.

I agree that adding new runtimes is currently too much brittle error-prone manual work. Moving forward, the best solution would be to pick up specification-based validations again as suggested by Thomas a while back: #7675 (comment)

Thank you for adding the validated test @alexrashed 🚀

@alexrashed
Copy link
Member Author

Thanks, @joe4dev for the review and the feedback! I added comments to both (RUNTIMES and IMAGE_MAPPING) and also added a simple unit test to ensure the set equality of the IMAGE_MAPPING keys and the RUNTIMES list.
Let me know what you think :)

Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea with the unit test 👍

LGTM 🚀

(agree that splitting these variables across api_utils and lambda_models is not the best idea)

@alexrashed alexrashed merged commit 464880d into master Aug 30, 2023
@alexrashed alexrashed deleted the fix-lambda-layer-compatibility-py311 branch August 30, 2023 13:33
ashish1500616 pushed a commit to ashish1500616/localstack that referenced this pull request Aug 31, 2023
@joe4dev
Copy link
Member

joe4dev commented Nov 22, 2023

@alexrashed The IMAGE_MAPPING and everything around Lambda runtimes is now consolidated and much easier to maintain #9697

Thanks for the input 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants