aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.53k stars 1.17k forks source link

Bug: sam local invoke - APIError #7668

Open aratatous opened 2 weeks ago

aratatous commented 2 weeks ago

Description:

Lambda Plugin run works fine, but debug fails

Steps to reproduce:

Try to run a lambda with Lambda AWS plugin in debug mode.

Observed result:

Error: 500 Server Error for http+docker://localhost/v1.35/containers/99ca22218a9b69add0520c8fa423ccf4039cf45cdca0abccb7f07076afe01215/start: Internal Server Error ("error while creating mount source path '/host_mnt/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev': mkdir /host_mnt/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev: file exists") Traceback: File "click/core.py", line 1078, in main File "click/core.py", line 1688, in invoke File "click/core.py", line 1688, in invoke File "click/core.py", line 1434, in invoke File "click/core.py", line 783, in invoke File "samcli/cli/cli_config_file.py", line 347, in wrapper File "click/decorators.py", line 92, in new_func File "click/core.py", line 783, in invoke File "samcli/lib/telemetry/metric.py", line 185, in wrapped File "samcli/lib/telemetry/metric.py", line 150, in wrapped File "samcli/lib/utils/version_checker.py", line 43, in wrapped File "samcli/cli/main.py", line 95, in wrapper File "samcli/commands/local/invoke/cli.py", line 108, in cli File "samcli/commands/local/invoke/cli.py", line 209, in do_cli File "samcli/commands/local/lib/local_lambda.py", line 166, in invoke File "samcli/lib/telemetry/metric.py", line 325, in wrapped_func File "samcli/local/lambdafn/runtime.py", line 227, in invoke File "samcli/local/lambdafn/runtime.py", line 177, in run File "samcli/local/docker/manager.py", line 118, in run File "samcli/local/docker/container.py", line 393, in start File "samcli/local/docker/container.py", line 389, in start File "docker/models/containers.py", line 420, in start File "docker/utils/decorators.py", line 19, in wrapped File "docker/api/container.py", line 1136, in start File "docker/api/client.py", line 277, in _raise_for_status File "docker/errors.py", line 39, in create_api_error_from_http_exception

An unexpected error was encountered while executing "sam local invoke".

Expected result:

I put debug break points in the code, and I expect IDE to stop at those break points for debugging Python Lambda code.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac OS version 15.1
  2. sam --version: SAM CLI, version 1.126.0
  3. AWS region: us-west-2 5-

    Paste the output of sam --info here

    % sam --info { "version": "1.127.0", "system": { "python": "3.11.10", "os": "macOS-15.1-arm64-arm-64bit" }, "additional_dependencies": { "docker_engine": "27.3.1", "aws_cdk": "Not available", "terraform": "Not available" }, "available_beta_feature_env_vars": [ "SAM_CLI_BETA_FEATURES", "SAM_CLI_BETA_BUILD_PERFORMANCE", "SAM_CLI_BETA_TERRAFORM_SUPPORT", "SAM_CLI_BETA_RUST_CARGO_LAMBDA" ] }

mndeveci commented 2 weeks ago

Are you using the AWS plugin for Pycharm here (https://aws.amazon.com/pycharm/)?