aws / aws/aws-sam-cli

--debug-port not working in SAM Local Invoke on Windows

Open
#7,477 4 comments 0 reactions 0 assignees View on GitHub
area/docker area/local/invoke stage/bug-repro
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:
When using the `sam local invoke` command on Windows, the `--debug-port` (or `-d`) argument does not seem to be applied, which prevents the debugging process from starting.

### Context:
I'm trying to start a debugging session with the following command:

```bash
sam local invoke myFunction--event tests\resources\events\mock-event.json --docker-network droide-common --container-host 127.0.0.1 --skip-pull-image --debug-port 9999
```

However, after running the command, there is no indication in the logs that the `--debug-port` option is being recognized. Here's a snippet from the logs:

```
No current session found, using default AWS::AccountId
Invoking Container created from my-local-lambda-image:latest
Building image.................
Requested to skip pulling images ...

START RequestId: a0c7a971-babc-4c91-92e4-caf36c600d06 Version: $LATEST
END RequestId
```

### Expected behavior:
The specified debug port should be opened and ready to accept a debugging connection, but this doesn't seem to happen.

### Environment:
- **Operating System**: Windows
- **SAM CLI Version**: Tested with versions 1.120 and 1.124
- **Docker Version**: 26.1.0-rd
- **Docker setup**: Running on WSL2
- **Custom Lambda Image**: Defined in `template.yml`

### Steps to reproduce:
1. Run the following command on Windows:
```bash
sam local invoke GetActifByNumeroMr --event tests\resources\events\mock-event.json --docker-network droide-common --container-host 127.0.0.1 --skip-pull-image --debug-port 9999
```

2. Check the logs, which do not show any indication that the `--debug-port` argument is recognized.

### Possible suggestions or fixes:
- Ensure that the `--debug-port` argument is correctly handled on Windows.
- Suggest any workarounds or fixes for enabling debugging properly.

Thank you for your assistance!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.