Repository navigation
fix(local): ignore --runtime override for Image package type functions - #9477
Open
mayankcodes-dev wants to merge 1 commit into
Open
mayankcodes-dev wants to merge 1 commit into
mayankcodes-dev wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) does this change fix?
#7996
Why is this change necessary?
Since
v1.135.0added--runtimetosam local invoke(#7885), callers such as AWS Toolkit for VS Code pass--runtime(for example--runtime python3.13) even when invokingPackageType: Imagefunctions.Imagefunctions define their runtime inside the container image (function.runtimeisNone), and callers pass full debug entrypoints via--debug-args(such as/var/lang/bin/python3.13 /tmp/lambci_debug_files/py_debug_wrapper.py ... /var/runtime/bootstrap.py). Settingconfig.runtimefromoverride_runtimeon anImagefunction causedLambdaDebugSettingsto prepend/var/lang/bin/python3.13and append/var/runtime/bootstrap.pya second time, making Python attempt to execute/var/lang/bin/python3.13as source (SyntaxError: source code cannot contain null bytes).How does it address the issue?
LocalLambdaRunner.get_invoke_config(samcli/commands/local/lib/local_lambda.py) to ignoreoverride_runtimewith a warning log whenfunction.packagetype == IMAGE, preservingfunction.runtime(None) while keepingoverride_runtimeworking identically forZipfunctions.LambdaContainer._resolve_debug_runtime(samcli/local/docker/lambda_container.py) soImagecontainers always passNonetoLambdaContainer._get_debug_settingseven if a non-Noneruntime is supplied directly.tests/unit/commands/local/lib/test_local_lambda.pyandtests/unit/local/docker/test_lambda_container.py.Verification
Verified locally on Windows with Python 3.13.5 (with generative AI assistance reviewed and verified by @mayankcodes-dev; no Docker or AWS calls needed):
black --check setup.py samcli tests schema:1408 files would be left unchanged.ruff check samcli schema:All checks passed!mypyonsetup.pyand the modified source and test files:Success: no issues found in 5 source filespytest tests/unit/commands/local/lib/test_local_lambda.py tests/unit/commands/local/invoke/test_cli.py tests/unit/local/docker/test_lambda_container.py tests/unit/local/docker/test_lambda_debug_settings.py --cov=samcli.commands.local.lib.local_lambda --cov=samcli.local.docker.lambda_container:246 passed in 11.42s(99%branch+stmt coverage onlocal_lambda.py,96%onlambda_container.py).pytest tests/unit/commands/local/ tests/unit/local/:2396 passed, 21 skipped, with17pre-existing Windows-only failures unrelated to this change (16POSIX/usr/...path expectations intest_sam_function_provider.pyand1Windows temp-lock test intest_file_lock.py).What side effects does this change have?
Passing
--runtimeon aPackageType: Imagefunction now logs a warning and keepsruntime=Noneinstead of applying Zip runtime debug wrappers.Zippackage type behavior is unchanged.Mandatory Checklist
PRs will only be reviewed after checklist is complete
make prpassesmake update-reproducible-reqsif dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.