fix lambda layer version compatibility with Python 3.11 by alexrashed · Pull Request #9020 · localstack/localstack · GitHub
Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

fix lambda layer version compatibility with Python 3.11#9020

Merged
alexrashed merged 2 commits into
masterfrom
fix-lambda-layer-compatibility-py311
Aug 30, 2023
Merged

fix lambda layer version compatibility with Python 3.11#9020
alexrashed merged 2 commits into
masterfrom
fix-lambda-layer-compatibility-py311

Conversation

@alexrashed

Copy link
Copy Markdown
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

coveralls commented Aug 30, 2023

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Aug 30, 2023

Copy link
Copy Markdown

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.

@joe4dev joe4dev left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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 :)

@joe4dev joe4dev left a comment

Copy link
Copy Markdown
Member

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

joe4dev commented Nov 22, 2023

Copy link
Copy Markdown
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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