Skip to content

fix(local): ignore --runtime override for Image package type functions - #9477

Open
mayankcodes-dev wants to merge 1 commit into
aws:developfrom
mayankcodes-dev:fix/ignore-runtime-override-for-image-functions
Open

mayankcodes-dev wants to merge 1 commit into
aws:developfrom
mayankcodes-dev:fix/ignore-runtime-override-for-image-functions

Conversation

@mayankcodes-dev

@mayankcodes-dev mayankcodes-dev commented Dec 2, 2026 •

Copy link
Copy Markdown

Which issue(s) does this change fix?

#7996

Why is this change necessary?

Since v1.135.0 added --runtime to sam local invoke (#7885), callers such as AWS Toolkit for VS Code pass --runtime (for example --runtime python3.13) even when invoking PackageType: Image functions.

Image functions define their runtime inside the container image (function.runtime is None), 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). Setting config.runtime from override_runtime on an Image function caused LambdaDebugSettings to prepend /var/lang/bin/python3.13 and append /var/runtime/bootstrap.py a second time, making Python attempt to execute /var/lang/bin/python3.13 as source (SyntaxError: source code cannot contain null bytes).

How does it address the issue?

  • Update LocalLambdaRunner.get_invoke_config (samcli/commands/local/lib/local_lambda.py) to ignore override_runtime with a warning log when function.packagetype == IMAGE, preserving function.runtime (None) while keeping override_runtime working identically for Zip functions.
  • Add LambdaContainer._resolve_debug_runtime (samcli/local/docker/lambda_container.py) so Image containers always pass None to LambdaContainer._get_debug_settings even if a non-None runtime is supplied directly.
  • Add regression unit tests in tests/unit/commands/local/lib/test_local_lambda.py and tests/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!
  • mypy on setup.py and the modified source and test files: Success: no issues found in 5 source files
  • pytest 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 on local_lambda.py, 96% on lambda_container.py).
  • Broad pytest tests/unit/commands/local/ tests/unit/local/: 2396 passed, 21 skipped, with 17 pre-existing Windows-only failures unrelated to this change (16 POSIX /usr/... path expectations in test_sam_function_provider.py and 1 Windows temp-lock test in test_file_lock.py).

What side effects does this change have?

Passing --runtime on a PackageType: Image function now logs a warning and keeps runtime=None instead of applying Zip runtime debug wrappers. Zip package type behavior is unchanged.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mayankcodes-dev
mayankcodes-dev requested a review from a team as a code owner December 2, 2026 13:34
Copilot AI balanced review requested due to automatic review settings December 2, 2026 13:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions github-actions Bot added area/local/start-api sam local start-api command area/local/invoke sam local invoke command area/local/start-invoke pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/local/invoke sam local invoke command area/local/start-api sam local start-api command area/local/start-invoke pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants