python lambda debug: missing "debugpy" with "buildArguments: --manifest..."
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 807
- Avg merge
- 10h 12m
- Merged PRs (30d)
- 7
Description
## System details (run the `AWS: About Toolkit` command)
- OS: Ubuntu 22.04.3 LTS
- Visual Studio Code version: 1.84.2
- AWS Toolkit version: v1.99.0
## Question
Hi guys, I'm having some problems compiling the project in debug mode, with the AWS Toolkit, due to versioning and structure problems in the project, made in python. We are currently fixing all these points, however we still can't compile the project, could you help us?
Below is the **AWS_TOOLKIT** log
```
2023-11-23 09:25:31 [INFO]: log level: info
2023-11-23 09:25:31 [INFO]: endpoints: retrieving AWS endpoints data
2023-11-23 09:25:31 [INFO]: OS: Linux x64 6.2.0-37-generic
2023-11-23 09:25:31 [INFO]: Visual Studio Code extension host: 1.84.2
2023-11-23 09:25:31 [INFO]: AWS Toolkit: 1.99.0
2023-11-23 09:25:31 [INFO]: node: 18.15.0
2023-11-23 09:25:31 [INFO]: electron: 25.9.2
2023-11-23 09:25:32 [INFO]: telemetry cache not found: '/home/xarpy/.config/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/telemetryCache'
2023-11-23 09:25:32 [WARN]: AwsContext: no default region in credentials profile, falling back to us-east-1:
2023-11-23 09:30:32 [INFO]: telemetry: sent batch (size=9)
2023-11-23 09:36:30 [INFO]: CloudFormationTemplateRegistry: building with: Watching **/*.{yaml,yml}, Untitled Files, Excluding /.*devfile\.(yaml|yml)/i, /.*[/\\]\.aws-sam([/\\].*|$)/
2023-11-23 09:36:30 [INFO]: CloudFormationTemplateRegistry: failed to process: file:///home/xarpy/project/payments/.pre-commit-config.yaml
2023-11-23 09:36:30 [INFO]: CloudFormationTemplateRegistry: failed to process: file:///home/xarpy/project/payments/specs/api/bau.yaml
2023-11-23 09:36:30 [INFO]: CloudFormationTemplateRegistry: failed to process: file:///home/xarpy/project/payments/specs/api/baul-webhook.yaml
2023-11-23 09:36:30 [INFO]: CloudFormationTemplateRegistry: processed 1 items, skipped 3
2023-11-23 09:36:30 [WARN]: SAM debug: missing AWS credentials (Toolkit is not connected)
2023-11-23 09:36:30 [INFO]: SAM CLI location (version: 1.103.0): /usr/local/bin/sam
2023-11-23 09:36:31 [INFO]: Preparing to debug locally: Lambda "app.lambda_handler"
2023-11-23 09:36:31 [INFO]: Building SAM application...
2023-11-23 09:36:31 [INFO]: SAM CLI not configured, using SAM found at: '/usr/local/bin/sam'
2023-11-23 09:36:31 [INFO]: Command: (not started) [/usr/local/bin/sam build --build-dir /tmp/aws-toolkit-vscode/vsctkTzYQ18/output --template /tmp/aws-toolkit-vscode/vsctkTzYQ18/app___vsctk___template.yaml --base-dir /home/xarpy/project/payments --manifest /tmp/aws-toolkit-vscode/vsctkTzYQ18/debug-requirements.txt --manifest requirements/dev.in]
2023-11-23 09:36:33 [INFO]: Build complete.
2023-11-23 09:36:33 [INFO]: Starting SAM application locally
2023-11-23 09:36:33 [INFO]: SAM CLI not configured, using SAM found at: '/usr/local/bin/sam'
2023-11-23 09:36:33 [INFO]: AWS.running.command
2023-11-23 09:36:33 [INFO]: Command: (not started) [/usr/local/bin/sam local invoke payments --template /tmp/aws-toolkit-vscode/vsctkTzYQ18/output/template.yaml --env-vars /tmp/aws-toolkit-vscode/vsctkTzYQ18/env-vars.json -d 5858 --debugger-path /home/xarpy/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.99.0/resources/debugger --debug-args /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5858 --wait-for-client --log-to-stderr]
2023-11-23 09:36:54 [INFO]: Attaching debugger to SAM application...
2023-11-23 09:37:10 [ERROR]: SamLaunchRequestError: Failed to attach debugger [DebuggerRetryLimit]
2023-11-23 09:40:33 [INFO]: telemetry: sent batch (size=3)
```
Another log, from output on vscode is this:
```
23 Nov 2023 12:36:52,306 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 1 InvokeID=
Prepending Lambda task root to path: /var/task
Starting debugger...
2023-11-23 09:36:52 [ERROR]: Traceback (most recent call last):
File "/tmp/lambci_debug_files/py_debug_wrapper.py", line 46, in
runpy.run_module('debugpy', run_name='__main__')
File "/var/lang/lib/python3.10/runpy.py", line 220, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "/var/lang/lib/python3.10/runpy.py", line 140, in _get_module_details
raise error("No module named { raw: true }" % mod_name)
ImportError: No module named debugpy
END RequestId: 1a4ade06-b5d7-4c23-ac01-95f2f65bd988
REPORT RequestId: 1a4ade06-b5d7-4c23-ac01-95f2f65bd988 Init Duration: 0.13 ms Duration: 43.80 ms Billed Duration: 44 ms Memory Size: 128 MB Max Memory Used: 128 MB
Command stopped: "sam local invoke"
2023-11-23 09:36:54 [INFO]: Attaching debugger to SAM application...
```
Even though I've already inserted the debugpy package into the requirements, this hasn't changed.
And my launch.json is that:
```
{
// Use o IntelliSense para saber mais sobre os atributos possíveis.
// Focalizar para exibir as descrições dos atributos existentes.
// Para obter mais informações, acesse: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "BP:Payments",
"invokeTarget": {
"target": "code",
"projectRoot": "payments",
"lambdaHandler": "app.lambda_handler"
// "templatePath": "${workspaceFolder}/payments/template.yaml",
// "logicalId": "BankPaymentStack"
},
"lambda": {
"runtime": "python3.10",
"payload": {},
"environmentVariables": {"ENV":"Dev"}
},
"sam":{
"buildArguments": ["--manifest", "requirements/dev.in"]
}
}
]
}
```
Yes, we have a template.yml, but it's more confusing to understand than the code itself, so much so that I can't compile the project either from the template.yml or from the code itself, and every time the system crashes it shows a connection error, unable to connect to port 5858.
Contributor guide
Research direction
Start with launch.json, requirements/dev.in, and the logged SAM build and local-invoke commands. Reproduce the app.lambda_handler debug flow and inspect why py_debug_wrapper.py cannot import debugpy despite the manifest configuration. Done means local invocation starts the debugger on port 5858 and attaches without the ImportError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, vscode
- Domain
- cloud, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100