SAM cli 1.13.2+ Go debugging broken
See original GitHub issueDescription:
Attempting to debug a go lambda with sam cli start-api/invoke makes the lambda code fail to start
Steps to reproduce:
- Create a sam app with these parameters using 1.13.2
-----------------------
Generating application:
-----------------------
Name: test113sam
Runtime: go1.x
Dependency Manager: mod
Application Template: hello-world
Output Directory: .
Next steps can be found in the README file at ./test113sam/README.md
sam build
- run
sam local invoke
it works fine:
$ sam local invoke
Invoking hello-world (go1.x)
Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-go1.x:rapid-1.13.2.
Mounting /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
START RequestId: d1f12116-37df-4127-9b64-36aacdccea8c Version: $LATEST
END RequestId: d1f12116-37df-4127-9b64-36aacdccea8c
REPORT RequestId: d1f12116-37df-4127-9b64-36aacdccea8c Init Duration: 1.57 ms Duration: 785.02 ms Billed Duration: 800 ms Memory Size: 128 MB Max Memory Used: 128 MB
{"statusCode":200,"headers":null,"multiValueHeaders":null,"body":"Hello, 72.21.198.67\n"}
Now, try invoking with Devle debugger args:
sam local invoke --debug-args -delveAPI=2 --debugger-path /Users/werlla/IdeaProjects/go1sam/ --debug-port 59394 --debug
2020-12-07 13:10:50,211 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-07 13:10:50,418 | local invoke command is called
2020-12-07 13:10:50,427 | No Parameters detected in the template
2020-12-07 13:10:50,454 | 2 resources found in the template
2020-12-07 13:10:50,455 | Found Serverless function with name='HelloWorldFunction' and CodeUri='HelloWorldFunction'
2020-12-07 13:10:50,464 | Found one Lambda function with name 'HelloWorldFunction'
2020-12-07 13:10:50,464 | Invoking hello-world (go1.x)
2020-12-07 13:10:50,464 | Environment variables overrides data is standard format
2020-12-07 13:10:50,464 | Loading AWS credentials from session with profile 'None'
2020-12-07 13:10:51,929 | Resolving code path. Cwd=/private/tmp/test113sam/.aws-sam/build, CodeUri=HelloWorldFunction
2020-12-07 13:10:51,929 | Resolved absolute path to code is /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction
2020-12-07 13:10:51,930 | Code /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction is not a zip/jar file
2020-12-07 13:10:53,185 | Failed to download image with name amazon/aws-sam-cli-emulation-image-go1.x:debug-1.13.2
2020-12-07 13:10:53,185 | Failed to download a new amazon/aws-sam-cli-emulation-image-go1.x:debug-1.13.2 image. Invoking with the already downloaded image.
2020-12-07 13:10:53,186 | Mounting /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
2020-12-07 13:10:53,859 | Setting up SIGTERM interrupt handler
2020/12/07 21:10:53 Error starting mock server: fork/exec /var/rapid/init: no such file or directory
2020-12-07 13:10:54,710 | No response from invoke container for HelloWorldFunction
2020-12-07 13:10:54,711 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'duration': 4498, 'exitReason': 'success', 'exitCode': 0, 'requestId': 'fd63fac1-9b23-4de9-a4ab-e6b76e979b13', 'installationId': '8e36c82e-d3f0-45b7-9e48-1e6f0ad535a6', 'sessionId': '10201463-def2-41d3-97ea-e2c5b3ee5e6f', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.13.2'}}]}
2020-12-07 13:10:54,880 | Telemetry response: 200
Observed result:
2020/12/07 21:10:53 Error starting mock server: fork/exec /var/rapid/init: no such file or directory
And it does not start.
sam local invoke --debug-args "-delveAPI=2" --debugger-path /Users/werlla/IdeaProjects/go1sam/ --debug-port 59394 --debug
Quoting debug args results in the same output, and single quoting debug args leads to some more strange output without it running
sam local invoke --debug-args '-delveAPI=2' --debugger-path /Users/werlla/IdeaProjects/go1sam/ --debug-port 59394 --debug
2020-12-07 13:15:41,148 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-07 13:15:41,541 | local invoke command is called
2020-12-07 13:15:41,548 | No Parameters detected in the template
2020-12-07 13:15:41,589 | 2 resources found in the template
2020-12-07 13:15:41,589 | Found Serverless function with name='HelloWorldFunction' and CodeUri='HelloWorldFunction'
2020-12-07 13:15:41,608 | Found one Lambda function with name 'HelloWorldFunction'
2020-12-07 13:15:41,608 | Invoking hello-world (go1.x)
2020-12-07 13:15:41,608 | Environment variables overrides data is standard format
2020-12-07 13:15:41,609 | Loading AWS credentials from session with profile 'None'
2020-12-07 13:15:43,363 | Resolving code path. Cwd=/private/tmp/test113sam/.aws-sam/build, CodeUri=HelloWorldFunction
2020-12-07 13:15:43,363 | Resolved absolute path to code is /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction
2020-12-07 13:15:43,363 | Code /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction is not a zip/jar file
2020-12-07 13:15:44,558 | Failed to download image with name amazon/aws-sam-cli-emulation-image-go1.x:debug-1.13.2
2020-12-07 13:15:44,558 | Failed to download a new amazon/aws-sam-cli-emulation-image-go1.x:debug-1.13.2 image. Invoking with the already downloaded image.
2020-12-07 13:15:44,558 | Mounting /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
2020-12-07 13:15:45,629 | Setting up SIGTERM interrupt handler
2020-12-07 13:15:46,391 | No response from invoke container for HelloWorldFunction
2020-12-07 13:15:46,392 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'duration': 5242, 'exitReason': 'success', 'exitCode': 0, 'requestId': '61ed57b7-4d4d-4081-b4b7-88af18a3ec2f', 'installationId': '8e36c82e-d3f0-45b7-9e48-1e6f0ad535a6', 'sessionId': 'a568cab5-a111-40a0-bfef-a9800ec0a2a4', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.13.2'}}]}
2020-12-07 13:15:46,521 | Telemetry response: 200
Expected result:
Running with the same arguments starts correctly with sam cli 1.12.0
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Mac
sam --version
: SAM CLI, version 1.13.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Step-through debugging Lambda functions locally
You can use AWS SAM with a variety of AWS toolkits and debuggers to test and debug your serverless applications locally.
Read more >aws-sam-cli Changelog - pyup.io
fix: broken integration tests due to new Go code binding in EB by hawflau in https://github.com/aws/aws-sam-cli/pull/3785
Read more >Bug listing with status UNCONFIRMED as at 2022/12/21 18 ...
Bug:128538 - "sys-apps/coreutils: /bin/hostname should be installed from coreutils not sys-apps/net-tools" status:UNCONFIRMED resolution: severity:enhancement ...
Read more >Package List — Spack 0.20.0.dev0 documentation
dnsmasq, py-azure-cli-command-modules-nspkg, r-gdata ... Description: ABI Dumper is a tool to dump ABI of an ELF object containing DWARF debug info.
Read more >Change: the logging - Nginx.org
Bugfix: nginx returned the 400 response on requests like "GET ... Changes with nginx 1.13.2 27 Jun 2017 *) Change: nginx now returns...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m also seeing this issue. I’ve set up the hello-world via sam init and pretty much did the same commands as above. So that is exactly the usecase which is described in the docs on how to debug with go.
Downgrading to v1.12.0 worked for me(Had to reinstall via pip
pip3 install --user 'aws-sam-cli==1.12.0'
)I tried with the new version 1.17.0 but i’m still not able to debug with goland. What surprised me was this in the logs
Ignoring unrecognized arguments: ['-delveAPI=2']
It tried with--debug-args "--api-version=2 --log"
as i’ve seen in your comment but againIgnoring unrecognized arguments: ['--api-version=2', '--log']
This might be a different issue but debugging as described in developer guide is still not possible. Went back to 1.12.0 and debugging is working again as described.