Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Rancher) SAM local invoke failed: Expecting value: line 1 column 1 #3786

Closed
stefanlduplessis opened this issue Aug 30, 2023 · 4 comments
Closed
Labels
documentation guidance General information and guidance, answers to FAQs, or recommended best practices/resources. sam

Comments

@stefanlduplessis
Copy link

Problem

I am having trouble debugging a lambda locally using sam + aws toolkit + rancher desktop (dockerd). The debugger never makes it to the breakpoint set withing my lambda.
However, when I quit rancher desktop and open docker desktop, not making any changes, the debugger hits the desired breakpoint.
Using rancher desktop due to work constraints.

Steps to reproduce the issue

Use the aws toolkit wizard to create the basic python3.7 (image) HelloWorld lambda, leaving all defaults as is with rancher desktop 1.9.1 (dockerd).

AWS Toolkit logs
08-30 08:57:41 [VERBOSE]: SAM debug: config: "lambda-python3.7:HelloWorldFunction"
2023-08-30 08:57:42 [VERBOSE]: samCliLocator: getLocation took 512ms
2023-08-30 08:57:42 [VERBOSE]: samCliLocator: getLocation took 481ms
2023-08-30 08:57:43 [DEBUG]: pythonCodeLensProvider.makePythonDebugManifest params: {
  "isImageLambda": true,
  "samProjectCodeRoot": "C:/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/hello_world",
  "outputDir": "C:\\Users\\stefa\\AppData\\Local\\Temp\\aws-toolkit-vscode\\vsctkaJ18Mn",
  "useIkpdb": false
}
2023-08-30 08:57:44 [VERBOSE]: samCliLocator: getLocation took 508ms
2023-08-30 08:57:44 [VERBOSE]: samCliLocator: getLocation took 642ms
2023-08-30 08:57:46 [INFO]: Preparing to debug locally: Lambda "HelloWorldFunction"
2023-08-30 08:57:46 [INFO]: Building SAM application...
2023-08-30 08:57:46 [VERBOSE]: samCliLocator: getLocation took 518ms
2023-08-30 08:57:46 [INFO]: Command: (not started) [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd build --debug --build-dir C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output --template C:/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/template.yaml]
2023-08-30 08:57:46 [INFO]: SAM CLI not configured, using SAM found at: 'C:\\Program Files\\Amazon\\AWSSAMCLI\\bin\\sam.cmd'
2023-08-30 08:57:46 [VERBOSE]: running: (not started) [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd build --debug --build-dir C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output --template C:/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/template.yaml]
2023-08-30 08:57:48 [VERBOSE]: stderr: 2023-08-30 08:57:48,980 | Using SAM Template at C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\template.yaml

2023-08-30 08:57:48 [VERBOSE]: stderr: 2023-08-30 08:57:48,986 | Config file location: C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\samconfig.toml
2023-08-30 08:57:48,986 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file at 'C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\samconfig.toml'...

2023-08-30 08:57:48 [VERBOSE]: stderr: 2023-08-30 08:57:48,986 | Configuration values successfully loaded.
2023-08-30 08:57:48,986 | Configuration values are: {'stack_name': 'lambda-python3.7', 'parallel': True}

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,009 | Using config file: samconfig.toml, config environment: default
2023-08-30 08:57:49,009 | Expand command line arguments to:
2023-08-30 08:57:49,009 | --template_file=C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\template.yaml --build_dir=C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output --parallel --mount_with=READ --cache_dir=.aws-sam\cache 

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,353 | 'build' command is called

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,358 | No Parameters detected in the template

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,393 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,393 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,394 | 0 stacks found in the template
2023-08-30 08:57:49,395 | No Parameters detected in the template

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,413 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2023-08-30 08:57:49,413 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,414 | 2 resources found in the stack 
2023-08-30 08:57:49,414 | Found Serverless function with name='HelloWorldFunction' and ImageUri='None'
2023-08-30 08:57:49,414 | --base-dir is not presented, adjusting uri ./hello_world relative to C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\template.yaml
2023-08-30 08:57:49,414 | --base-dir is not presented, adjusting uri . relative to C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\template.yaml

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,422 | 2 resources found in the stack 
2023-08-30 08:57:49,422 | Found Serverless function with name='HelloWorldFunction' and ImageUri='None'

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,423 | Error occurred while trying to track an event: Event 'BuildFunctionRuntime' does not accept value 'None'.
2023-08-30 08:57:49,423 | Instantiating build definitions

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,423 | No previous build graph found, generating new one
2023-08-30 08:57:49,423 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(None, C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7, Image, , 2ed73201-ee04-45dd-b074-8ffb8ab723aa, {'DockerTag': 'python3.7-v1', 'DockerContext': 'C:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7\\hello_world', 'Dockerfile': 'Dockerfile'}, {}, x86_64, []), Function: Function(function_id='HelloWorldFunction', name='HelloWorldFunction', functionname='HelloWorldFunction', runtime=None, memory=128, timeout=3, handler=None, imageuri=None, packagetype='Image', imageconfig=None, codeuri='C:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'Api', 'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'DockerTag': 'python3.7-v1', 'DockerContext': 'C:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7\\hello_world', 'Dockerfile': 'Dockerfile', 'SamResourceId': 'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None, architectures=None, function_url_config=None, function_build_info=<FunctionBuildInfo.BuildableImage: ('BuildableImage', 'Regular IMAGE function which can be build with SAM CLI')>, stack_path='', runtime_management_config=None))

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,427 | Async execution started
2023-08-30 08:57:49,427 | Invoking function functools.partial(<bound method ParallelBuildStrategy.build_single_function_definition of <samcli.lib.build.build_strategy.ParallelBuildStrategy object at 0x0000018261202760>>, <samcli.lib.build.build_graph.FunctionBuildDefinition object at 0x00000182612029D0>)

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,427 | Building codeuri: C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7 runtime: None metadata: {'DockerTag': 'python3.7-v1', 'DockerContext': 'C:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7\\hello_world', 'Dockerfile': 'Dockerfile'} architecture: x86_64 functions: HelloWorldFunction

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,428 | Waiting for async results
2023-08-30 08:57:49,428 | Building to following folder C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\HelloWorldFunction
2023-08-30 08:57:49,428 | Building image for HelloWorldFunction function

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,434 | Setting DockerBuildArgs: {'SAM_BUILD_MODE': 'debug'} for HelloWorldFunction function

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,549 | <Image: 'helloworldfunction:python3.7-v1-debug'> image is built for HelloWorldFunction function
Step 1/5 : FROM sam-37:latest
 ---> 2fbe7b36194d
Step 2/5 : COPY requirements.txt ./
 ---> Using cache
 ---> 9b03941b317d
Step 3/5 : RUN python3.7 -m pip install -r requirements.txt -t .
 ---> Using cache
 ---> 11b94b48b093
Step 4/5 : COPY app.py ./
 ---> Using cache
 ---> 65b1bd928272
Step 5/5 : CMD ["app.lambda_handler"]
 ---> Using cache
 ---> ecbf24e87629
[Warning] One or more build-args [SAM_BUILD_MODE] were not consumed
Successfully built ecbf24e87629
Successfully tagged helloworldfunction:python3.7-v1-debug

2023-08-30 08:57:49 [VERBOSE]: stderr: 

2023-08-30 08:57:49,550 | Async execution completed
2023-08-30 08:57:49,550 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,550 | 2 resources found in the stack 
2023-08-30 08:57:49,550 | Found Serverless function with name='HelloWorldFunction' and ImageUri='None'

2023-08-30 08:57:49 [VERBOSE]: stdout: 
Build Succeeded

2023-08-30 08:57:49 [VERBOSE]: stdout: 
Built Artifacts  : ..\..\..\..\..\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output
Built Template   : ..\..\..\..\..\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml

Commands you can use next
=========================
[*] Validate SAM template: sam validate

[*] Invoke Function: sam local invoke -t ..\..\..\..\..\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml

[*] Test Function in the Cloud: sam sync --stack-name {{stack-name}} --watch

[*] Deploy: sam deploy --guided --template-file ..\..\..\..\..\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,555 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,688 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,688 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '207f2dae-8ca8-4560-9f44-f91e9c430a78', 'installationId': '2a9c0372-d164-4559-9473-891fe8ff1342', 'sessionId': 'f57962fc-1bfa-48f7-a37e-bde9855e5b82', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.95.0', 'userAgent': 'AWS-Toolkit-For-VSCode/1.86.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '72cbd93418a3a735d3606fa797f6a206de6fa77e8ec999eca282177944e4f2c7', 'initialCommit': None}, 'duration': 546, 'exitReason': 'success', 'exitCode': 0}}]}

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,688 | Unable to find Click Context for getting session_id.

2023-08-30 08:57:49 [VERBOSE]: stderr: 2023-08-30 08:57:49,692 | Sending Telemetry: {'metrics': [{'events': {'requestId': 'be0c99a4-5b0e-4560-9c88-eebf7dbdd7fd', 'installationId': '2a9c0372-d164-4559-9473-891fe8ff1342', 'sessionId': 'f57962fc-1bfa-48f7-a37e-bde9855e5b82', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.95.0', 'userAgent': 'AWS-Toolkit-For-VSCode/1.86.0', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '93cfb7dc06d1440583d76d865a367a46', 'time_stamp': '2023-08-30 12:57:48.985', 'exception_name': None}]}}}]}

2023-08-30 08:57:50 [VERBOSE]: stderr: 2023-08-30 08:57:50,208 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

2023-08-30 08:57:50 [VERBOSE]: stderr: 2023-08-30 08:57:50,223 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

2023-08-30 08:57:50 [INFO]: Build complete.
2023-08-30 08:57:50 [DEBUG]: localLambdaRunner.invokeLambdaFunction: lambda-python3.7:HelloWorldFunction
2023-08-30 08:57:50 [INFO]: Starting SAM application locally
2023-08-30 08:57:50 [VERBOSE]: samCliLocator: getLocation took 505ms
2023-08-30 08:57:50 [INFO]: AWS.running.command
2023-08-30 08:57:50 [INFO]: SAM CLI not configured, using SAM found at: 'C:\\Program Files\\Amazon\\AWSSAMCLI\\bin\\sam.cmd'
2023-08-30 08:57:50 [INFO]: Command: (not started) [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd local invoke --debug HelloWorldFunction --template C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml -d 5858 --skip-pull-image --debugger-path c:\Users\stefa\.vscode\extensions\amazonwebservices.aws-toolkit-vscode-1.86.0\resources\debugger --debug-args /var/lang/bin/python3.7 /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5858 --wait-for-client --log-to-stderr /var/runtime/bootstrap --debug] (running processes: 0)
2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,189 | Using SAM Template at C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,190 | No config file found in this directory.
2023-08-30 08:57:53,190 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: 'C:\\Users\\stefa\\AppData\\Local\\Temp\\aws-toolkit-vscode\\vsctkaJ18Mn\\output\\samconfig.toml'
2023-08-30 08:57:53,190 | Config file location: C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\samconfig.toml
2023-08-30 08:57:53,190 | Config file 'C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\samconfig.toml' does not exist

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,213 | Using config file: samconfig.toml, config environment: default
2023-08-30 08:57:53,213 | Expand command line arguments to:
2023-08-30 08:57:53,213 | --template_file=C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml --debug_port=(5858,) --skip_pull_image --debugger_path=c:\Users\stefa\.vscode\extensions\amazonwebservices.aws-toolkit-vscode-1.86.0\resources\debugger --debug_args=/var/lang/bin/python3.7 /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5858 --wait-for-client --log-to-stderr /var/runtime/bootstrap --debug --function_logical_id=HelloWorldFunction --no_event --layer_cache_basedir=C:\Users\stefa\AppData\Roaming\AWS SAM\layers-pkg --container_host=localhost --container_host_interface=127.0.0.1 

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,213 | local invoke command is called

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,218 | No Parameters detected in the template

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,253 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is HelloWorldFunction
2023-08-30 08:57:53,253 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,254 | 0 stacks found in the template
2023-08-30 08:57:53,254 | No Parameters detected in the template

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,272 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is HelloWorldFunction
2023-08-30 08:57:53,272 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,272 | 2 resources found in the stack 

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,273 | Found Serverless function with name='HelloWorldFunction' and ImageUri='helloworldfunction:python3.7-v1-debug'
2023-08-30 08:57:53,273 | --base-dir is not presented, adjusting uri C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\hello_world relative to C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml
2023-08-30 08:57:53,273 | --base-dir is not presented, adjusting uri . relative to C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,282 | Found one Lambda function with name 'HelloWorldFunction'
2023-08-30 08:57:53,282 | Invoking Container created from helloworldfunction:python3.7-v1-debug

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,282 | No environment variables found for function 'HelloWorldFunction'
2023-08-30 08:57:53,282 | Loading AWS credentials from session with profile 'None'

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,295 | Code None is not a zip/jar file

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: Building image...
2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: ...
2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: .........
2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: .
2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: .
2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 

2023-08-30 08:57:53,465 | Passing entrypoint as specified in template

2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,473 | Requested to skip pulling images ...


2023-08-30 08:57:53 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:53,965 | Setting up SIGTERM interrupt handler

2023-08-30 08:57:54 [VERBOSE]: SAM: pid 29244: stderr: START RequestId: 2ed60b44-f20b-4d24-a7f8-2c4a70a7d887 Version: $LATEST

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: /var/lang/bin/python3.7: can't open file '/tmp/lambci_debug_files/py_debug_wrapper.py': [Errno 2] No such file or directory

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 30 Aug 2023 12:57:55,029 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 2 InvokeID=

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: /var/lang/bin/python3.7: can't open file '/tmp/lambci_debug_files/py_debug_wrapper.py': [Errno 2] No such file or directory

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: END RequestId: b4bcd515-679d-4f27-b089-b09a7ce203eb
REPORT RequestId: b4bcd515-679d-4f27-b089-b09a7ce203eb	Init Duration: 0.33 ms	Duration: 49.91 ms	Billed Duration: 50 ms	Memory Size: 128 MB	Max Memory Used: 128 MB	

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:55,389 | Cleaning all decompressed code dirs

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:55,389 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:55,516 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:55,516 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '96157c51-adf0-44ce-9f83-80ef85478f11', 'installationId': '2a9c0372-d164-4559-9473-891fe8ff1342', 'sessionId': '0d23fee6-b7c4-4df6-9bdc-67d17f9272b0', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.95.0', 'userAgent': 'AWS-Toolkit-For-VSCode/1.86.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': 'aeb7de8e677ca6827ca89f2955cadd42ad4221a768d32db36d8403d1b95a3d5a', 'initialCommit': None}, 'duration': 2175, 'exitReason': 'JSONDecodeError', 'exitCode': 255}}]}
2023-08-30 08:57:55,516 | Unable to find Click Context for getting session_id.

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:55,518 | Sending Telemetry: {'metrics': [{'events': {'requestId': '1d5f96dc-39cd-4233-8764-6ad3792664f5', 'installationId': '2a9c0372-d164-4559-9473-891fe8ff1342', 'sessionId': '0d23fee6-b7c4-4df6-9bdc-67d17f9272b0', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.95.0', 'userAgent': 'AWS-Toolkit-For-VSCode/1.86.0', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '1eeff59c4c7441379b0d05d1964044de', 'time_stamp': '2023-08-30 12:57:53.190', 'exception_name': None}]}}}]}

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:55,986 | Telemetry response: 200

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 2023-08-30 08:57:55,988 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: 
Error: Expecting value: line 1 column 1 (char 0)
Traceback:
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 184, in wrapped
    raise exception  # pylint: disable=raising-bad-type
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 149, in wrapped
    return_value = func(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\version_checker.py", line 42, in wrapped
    actual_result = func(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\cli\main.py", line 95, in wrapper
    return func(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\invoke\cli.py", line 100, in cli
    do_cli(
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\invoke\cli.py", line 206, in do_cli
    context.local_lambda_runner.invoke(
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\lib\local_lambda.py", line 144, in invoke
    self.local_runtime.invoke(
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 324, in wrapped_func
    return_value = func(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\lambdafn\runtime.py", line 201, in invoke
    container.wait_for_result(
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 354, in wait_for_result
    response = self.wait_for_http_response(full_path, event, stdout)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\retry.py", line 30, in wrapper
    return func(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 334, in wait_for_http_response
    return json.dumps(json.loads(resp.content), ensure_ascii=False)
  File "json\__init__.py", line 357, in loads
  File "json\decoder.py", line 337, in decode
  File "json\decoder.py", line 355, in raw_decode


2023-08-30 08:57:55 [VERBOSE]: SAM: pid 29244: stderr: An unexpected error was encountered while executing "sam local invoke".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20local%20invoke%20-%20JSONDecodeError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20local%20invoke%20-%20JSONDecodeError

2023-08-30 08:57:56 [VERBOSE]: SAM: command exited (code: 1): PID 29244: [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd local invoke --debug HelloWorldFunction --template C:\Users\stefa\AppData\Local\Temp\aws-toolkit-vscode\vsctkaJ18Mn\output\template.yaml -d 5858 --skip-pull-image --debugger-path c:\Users\stefa\.vscode\extensions\amazonwebservices.aws-toolkit-vscode-1.86.0\resources\debugger --debug-args /var/lang/bin/python3.7 /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5858 --wait-for-client --log-to-stderr /var/runtime/bootstrap --debug]
2023-08-30 08:57:56 [ERROR]: SamLaunchRequestError: SAM local invoke failed: Expecting value: line 1 column 1 (char 0)
.vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "aws-sam",
            "request": "direct-invoke",
            "name": "lambda-python3.7:HelloWorldFunction",
            "invokeTarget": {
                "target": "template",
                "templatePath": "${workspaceFolder}/template.yaml",
                "logicalId": "HelloWorldFunction"
            },
            "lambda": {
                "payload": {},
                "environmentVariables": {},
                "runtime": "python3.7"
            },
        }
    ]
}
Dockerfile
FROM public.ecr.aws/lambda/python:3.7

COPY requirements.txt ./
RUN python3.7 -m pip install -r requirements.txt -t .

COPY app.py ./

# Command can be overwritten by providing a different command in the template directly.
CMD ["app.lambda_handler"]
requirements.txt
requests
debugpy>=1.0,<2
template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  lambda-python3.7

  Sample SAM Template for lambda-python3.7

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 3
    MemorySize: 128

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      PackageType: Image
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /hello
            Method: get
    Metadata:
      DockerTag: python3.7-v1
      DockerContext: ./hello_world
      Dockerfile: Dockerfile

Outputs:
  # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
  # Find out more about other implicit resources you can reference within SAM
  # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
  HelloWorldApi:
    Description: "API Gateway endpoint URL for Prod stage for Hello World function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
  HelloWorldFunction:
    Description: "Hello World Lambda Function ARN"
    Value: !GetAtt HelloWorldFunction.Arn
  HelloWorldFunctionIamRole:
    Description: "Implicit IAM Role created for Hello World function"
    Value: !GetAtt HelloWorldFunctionRole.Arn

Expected behavior

The debugger should stop at the desired breakpoint within the lambda.

System details (run the AWS: About Toolkit command)

  • OS: Windows_NT x64 10.0.22621
  • Visual Studio Code extension host: 1.81.1
  • AWS Toolkit: 1.86.0
  • node: 16.17.1
  • electron: 22.3.18
@stefanlduplessis stefanlduplessis added the bug We can reproduce the issue and confirmed it is a bug. label Aug 30, 2023
@justinmk3 justinmk3 added the sam label Aug 30, 2023
@justinmk3
Copy link
Contributor

justinmk3 commented Aug 30, 2023

Thanks for the very clear report! Rancher is reported as working with SAM CLI but it requires some setup. Some notes are in #3413 , starting with this comment: #3413 (comment)

@justinmk3 justinmk3 added the needs-response Waiting on reply from issue/PR author. label Aug 30, 2023
@stefanlduplessis
Copy link
Author

@justinmk3 Thank you for the quick response. I tried the above mentioned resources with no success.

I need to add another piece of the puzzle: I get a "Failed to attach debugger" error sometimes:

Logs: Failed to attach debugger
2023-08-30 13:30:48 [VERBOSE]: SAM debug: config: "lambda-python3.7:HelloWorldFunction"
2023-08-30 13:30:49 [DEBUG]: pythonCodeLensProvider.makePythonDebugManifest params: {
  "isImageLambda": true,
  "samProjectCodeRoot": "C:/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/hello_world",
  "outputDir": "c:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7\\builds",
  "useIkpdb": false
}
2023-08-30 13:30:50 [INFO]: Preparing to debug locally: Lambda "HelloWorldFunction"
2023-08-30 13:30:50 [INFO]: Building SAM application...
2023-08-30 13:30:50 [VERBOSE]: running: (not started) [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd build --debug --build-dir c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output --template C:/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/template.yaml]
2023-08-30 13:30:50 [INFO]: Command: (not started) [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd build --debug --build-dir c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output --template C:/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/template.yaml]
2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,381 | Using SAM Template at C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\template.yaml

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,381 | Config file location: C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\samconfig.toml
2023-08-30 13:30:52,381 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file at 'C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\samconfig.toml'...
2023-08-30 13:30:52,381 | Configuration values successfully loaded.
2023-08-30 13:30:52,381 | Configuration values are: {'stack_name': 'lambda-python3.7', 'parallel': True}

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,414 | Using config file: samconfig.toml, config environment: default
2023-08-30 13:30:52,414 | Expand command line arguments to:
2023-08-30 13:30:52,414 | --template_file=C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\template.yaml --build_dir=c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output --parallel --mount_with=READ --cache_dir=.aws-sam\cache 

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,693 | 'build' command is called

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,696 | No Parameters detected in the template

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,725 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2023-08-30 13:30:52,725 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,726 | 0 stacks found in the template
2023-08-30 13:30:52,726 | No Parameters detected in the template

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,741 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2023-08-30 13:30:52,741 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2023-08-30 13:30:52,741 | 2 resources found in the stack 

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,741 | Found Serverless function with name='HelloWorldFunction' and ImageUri='None'
2023-08-30 13:30:52,741 | --base-dir is not presented, adjusting uri ./hello_world relative to C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\template.yaml
2023-08-30 13:30:52,742 | --base-dir is not presented, adjusting uri . relative to C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\template.yaml

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,746 | 2 resources found in the stack 
2023-08-30 13:30:52,746 | Found Serverless function with name='HelloWorldFunction' and ImageUri='None'

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,748 | Error occurred while trying to track an event: Event 'BuildFunctionRuntime' does not accept value 'None'.
2023-08-30 13:30:52,748 | Instantiating build definitions

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,757 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(None, C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7, Image, , a231edc6-8cf8-4007-ba5f-586cd7885218, {'DockerTag': 'python3.7-v1', 'DockerContext': 'C:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7\\hello_world', 'Dockerfile': 'Dockerfile'}, {}, x86_64, []), Function: Function(function_id='HelloWorldFunction', name='HelloWorldFunction', functionname='HelloWorldFunction', runtime=None, memory=128, timeout=3, handler=None, imageuri=None, packagetype='Image', imageconfig=None, codeuri='C:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'Api', 'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'DockerTag': 'python3.7-v1', 'DockerContext': 'C:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7\\hello_world', 'Dockerfile': 'Dockerfile', 'SamResourceId': 'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None, architectures=None, function_url_config=None, function_build_info=<FunctionBuildInfo.BuildableImage: ('BuildableImage', 'Regular IMAGE function which can be build with SAM CLI')>, stack_path='', runtime_management_config=None))

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,760 | Async execution started
2023-08-30 13:30:52,760 | Invoking function functools.partial(<bound method ParallelBuildStrategy.build_single_function_definition of <samcli.lib.build.build_strategy.ParallelBuildStrategy object at 0x00000207E93FA820>>, <samcli.lib.build.build_graph.FunctionBuildDefinition object at 0x00000207E933BF70>)

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,761 | Building codeuri: C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7 runtime: None metadata: {'DockerTag': 'python3.7-v1', 'DockerContext': 'C:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7\\hello_world', 'Dockerfile': 'Dockerfile'} architecture: x86_64 functions: HelloWorldFunction

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,762 | Building to following folder C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\HelloWorldFunction
2023-08-30 13:30:52,762 | Building image for HelloWorldFunction function
2023-08-30 13:30:52,762 | Waiting for async results

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,767 | Setting DockerBuildArgs: {'SAM_BUILD_MODE': 'debug'} for HelloWorldFunction function

2023-08-30 13:30:52 [VERBOSE]: CloudFormationTemplateRegistry: detected delete: c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\template.yaml
2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,858 | <Image: 'helloworldfunction:python3.7-v1-debug'> image is built for HelloWorldFunction function
Step 1/5 : FROM public.ecr.aws/lambda/python:3.7
 ---> 666571853a2b
Step 2/5 : COPY requirements.txt ./
 ---> Using cache
 ---> e9b6b7071aee
Step 3/5 : RUN python3.7 -m pip install -r requirements.txt -t .
 ---> Using cache
 ---> 6457d6a3c7be
Step 4/5 : COPY app.py ./
 ---> Using cache
 ---> 973d563fbe30
Step 5/5 : CMD ["app.lambda_handler"]
 ---> Using cache
 ---> 87a3c0c3b2ca
[Warning] One or more build-args [SAM_BUILD_MODE] were not consumed
Successfully built 87a3c0c3b2ca
Successfully tagged helloworldfunction:python3.7-v1-debug



2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,859 | Async execution completed
2023-08-30 13:30:52,859 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,859 | 2 resources found in the stack 
2023-08-30 13:30:52,860 | Found Serverless function with name='HelloWorldFunction' and ImageUri='None'

2023-08-30 13:30:52 [VERBOSE]: stdout: 
Build Succeeded

2023-08-30 13:30:52 [VERBOSE]: stdout: 
Built Artifacts  : builds\output
Built Template   : builds\output\template.yaml

Commands you can use next
=========================
[*] Validate SAM template: sam validate

[*] Invoke Function: sam local invoke -t builds\output\template.yaml

[*] Test Function in the Cloud: sam sync --stack-name {{stack-name}} --watch

[*] Deploy: sam deploy --guided --template-file builds\output\template.yaml

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,863 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,993 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-08-30 13:30:52,993 | Unable to find Click Context for getting session_id.

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,994 | Sending Telemetry: {'metrics': [{'events': {'requestId': 'f48bf2e7-dc6d-434a-8be7-5cadda2a9184', 'installationId': '2a9c0372-d164-4559-9473-891fe8ff1342', 'sessionId': '50abf9a3-7276-4bd0-95c5-022643a3c097', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.95.0', 'userAgent': 'AWS-Toolkit-For-VSCode/1.86.0', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': 'fe93c2e8abdc4589bc4c3efd9e5ec78e', 'time_stamp': '2023-08-30 17:30:52.381', 'exception_name': None}]}}}]}

2023-08-30 13:30:52 [VERBOSE]: stderr: 2023-08-30 13:30:52,994 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '02be11db-3990-4a2a-9f0b-a7a3204f8554', 'installationId': '2a9c0372-d164-4559-9473-891fe8ff1342', 'sessionId': '50abf9a3-7276-4bd0-95c5-022643a3c097', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.95.0', 'userAgent': 'AWS-Toolkit-For-VSCode/1.86.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '72cbd93418a3a735d3606fa797f6a206de6fa77e8ec999eca282177944e4f2c7', 'initialCommit': None}, 'duration': 449, 'exitReason': 'success', 'exitCode': 0}}]}

2023-08-30 13:30:52 [VERBOSE]: CloudFormationTemplateRegistry: detected new file: c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\template.yaml
2023-08-30 13:30:53 [VERBOSE]: stderr: 2023-08-30 13:30:53,525 | Telemetry response: 200

2023-08-30 13:30:53 [VERBOSE]: stderr: 2023-08-30 13:30:53,531 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

2023-08-30 13:30:53 [DEBUG]: schema service: handle yaml mapping: [removed] -> file:///c%3A/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/builds/output/template.yaml
2023-08-30 13:30:53 [DEBUG]: schema service: handle yaml mapping: sam -> file:///c%3A/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/builds/output/template.yaml
2023-08-30 13:30:53 [INFO]: Build complete.
2023-08-30 13:30:53 [DEBUG]: localLambdaRunner.invokeLambdaFunction: lambda-python3.7:HelloWorldFunction
2023-08-30 13:30:53 [INFO]: Starting SAM application locally
2023-08-30 13:30:53 [INFO]: Command: (not started) [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd local invoke --debug HelloWorldFunction --template c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\template.yaml -d 5858 --skip-pull-image --debugger-path c:\Users\stefa\.vscode\extensions\amazonwebservices.aws-toolkit-vscode-1.86.0\resources\debugger --debug-args /var/lang/bin/python3.7 /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5858 --wait-for-client --log-to-stderr /var/runtime/bootstrap --debug] (running processes: 0)
2023-08-30 13:30:53 [INFO]: AWS.running.command
2023-08-30 13:30:55 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:55,918 | Using SAM Template at c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\template.yaml

2023-08-30 13:30:55 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:55,918 | No config file found in this directory.
2023-08-30 13:30:55,918 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: 'c:\\Users\\stefa\\Documents\\Work\\sam-build\\test\\lambda-python3.7\\builds\\output\\samconfig.toml'
2023-08-30 13:30:55,918 | Config file location: c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\samconfig.toml
2023-08-30 13:30:55,918 | Config file 'c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\samconfig.toml' does not exist

2023-08-30 13:30:55 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:55,939 | Using config file: samconfig.toml, config environment: default
2023-08-30 13:30:55,939 | Expand command line arguments to:
2023-08-30 13:30:55,939 | --template_file=c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\template.yaml --debug_port=(5858,) --skip_pull_image --debugger_path=c:\Users\stefa\.vscode\extensions\amazonwebservices.aws-toolkit-vscode-1.86.0\resources\debugger --debug_args=/var/lang/bin/python3.7 /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5858 --wait-for-client --log-to-stderr /var/runtime/bootstrap --debug --function_logical_id=HelloWorldFunction --no_event --layer_cache_basedir=C:\Users\stefa\AppData\Roaming\AWS SAM\layers-pkg --container_host=localhost --container_host_interface=127.0.0.1 
2023-08-30 13:30:55,939 | local invoke command is called

2023-08-30 13:30:55 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:55,944 | No Parameters detected in the template

2023-08-30 13:30:55 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:55,972 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is HelloWorldFunction
2023-08-30 13:30:55,972 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id

2023-08-30 13:30:55 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:55,973 | 0 stacks found in the template
2023-08-30 13:30:55,973 | No Parameters detected in the template

2023-08-30 13:30:55 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:55,988 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is HelloWorldFunction
2023-08-30 13:30:55,989 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2023-08-30 13:30:55,989 | 2 resources found in the stack 

2023-08-30 13:30:55 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:55,990 | Found Serverless function with name='HelloWorldFunction' and ImageUri='helloworldfunction:python3.7-v1-debug'
2023-08-30 13:30:55,990 | --base-dir is not presented, adjusting uri C:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\hello_world relative to c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\template.yaml
2023-08-30 13:30:55,990 | --base-dir is not presented, adjusting uri . relative to c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\template.yaml

2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:56,001 | Found one Lambda function with name 'HelloWorldFunction'
2023-08-30 13:30:56,001 | Invoking Container created from helloworldfunction:python3.7-v1-debug
2023-08-30 13:30:56,001 | No environment variables found for function 'HelloWorldFunction'
2023-08-30 13:30:56,001 | Loading AWS credentials from session with profile 'None'

2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:56,011 | Code None is not a zip/jar file

2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: Building image...
2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: ..
2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: ..........
2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: .
2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: .
2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: 

2023-08-30 13:30:56,171 | Passing entrypoint as specified in template

2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:56,182 | Requested to skip pulling images ...


2023-08-30 13:30:56 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:30:56,558 | Setting up SIGTERM interrupt handler

2023-08-30 13:31:07 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:31:07,307 | Cleaning all decompressed code dirs
2023-08-30 13:31:07,307 | No response from invoke container for HelloWorldFunction

2023-08-30 13:31:07 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:31:07,307 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2023-08-30 13:31:07 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:31:07,494 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2023-08-30 13:31:07 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:31:07,494 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '3f3ae65b-bb16-4fd7-b598-7cc82aee3dc8', 'installationId': '2a9c0372-d164-4559-9473-891fe8ff1342', 'sessionId': 'd3d6c267-c582-442c-b011-7a556ce0e419', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.95.0', 'userAgent': 'AWS-Toolkit-For-VSCode/1.86.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': 'aeb7de8e677ca6827ca89f2955cadd42ad4221a768d32db36d8403d1b95a3d5a', 'initialCommit': None}, 'duration': 11367, 'exitReason': 'success', 'exitCode': 0}}]}
2023-08-30 13:31:07,494 | Unable to find Click Context for getting session_id.

2023-08-30 13:31:07 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:31:07,496 | Sending Telemetry: {'metrics': [{'events': {'requestId': '2b5dbe8b-06e1-41c2-8a55-31879dfa26fe', 'installationId': '2a9c0372-d164-4559-9473-891fe8ff1342', 'sessionId': 'd3d6c267-c582-442c-b011-7a556ce0e419', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.95.0', 'userAgent': 'AWS-Toolkit-For-VSCode/1.86.0', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '39941be093ca41a8a3b230a44e5966f2', 'time_stamp': '2023-08-30 17:30:55.918', 'exception_name': None}]}}}]}

2023-08-30 13:31:07 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:31:07,912 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

2023-08-30 13:31:07 [VERBOSE]: SAM: pid 8628: stderr: 2023-08-30 13:31:07,928 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

2023-08-30 13:31:08 [VERBOSE]: SAM: command exited (code: 0): PID 8628: [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd local invoke --debug HelloWorldFunction --template c:\Users\stefa\Documents\Work\sam-build\test\lambda-python3.7\builds\output\template.yaml -d 5858 --skip-pull-image --debugger-path c:\Users\stefa\.vscode\extensions\amazonwebservices.aws-toolkit-vscode-1.86.0\resources\debugger --debug-args /var/lang/bin/python3.7 /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5858 --wait-for-client --log-to-stderr /var/runtime/bootstrap --debug]
2023-08-30 13:31:08 [INFO]: Attaching debugger to SAM application...
2023-08-30 13:31:08 [DEBUG]: localLambdaRunner.attachDebugger: startDebugging with config: {
  "name": "lambda-python3.7:HelloWorldFunction",
  "invokeTarget": {
    "target": "template",
    "templatePath": "C:/Users/stefa/Documents/Work/sam-build/test/lambda-python3.7/template.yaml",
    "logicalId": "HelloWorldFunction"
  }
}
2023-08-30 13:31:11 [DEBUG]: attachDebugger: retrying...
2023-08-30 13:31:15 [DEBUG]: attachDebugger: retrying...
2023-08-30 13:31:17 [DEBUG]: attachDebugger: retrying...
2023-08-30 13:31:19 [DEBUG]: attachDebugger: retrying...
2023-08-30 13:31:21 [DEBUG]: attachDebugger: retrying...
2023-08-30 13:31:23 [DEBUG]: attachDebugger: retrying...
2023-08-30 13:31:25 [DEBUG]: attachDebugger: retrying...
2023-08-30 13:31:26 [DEBUG]: attachDebugger: retrying...
2023-08-30 13:31:28 [ERROR]: SamLaunchRequestError: Failed to attach debugger [DebuggerRetryLimit]

@justinmk3 justinmk3 changed the title SamLaunchRequestError: SAM local invoke failed: Expecting value: line 1 column 1 (char 0) [Rancher] (Rancher) SAM local invoke failed: Expecting value: line 1 column 1 (char 0) [Rancher] Aug 31, 2023
@justinmk3 justinmk3 changed the title (Rancher) SAM local invoke failed: Expecting value: line 1 column 1 (char 0) [Rancher] (Rancher) SAM local invoke failed: Expecting value: line 1 column 1 (char 0) Aug 31, 2023
@justinmk3 justinmk3 changed the title (Rancher) SAM local invoke failed: Expecting value: line 1 column 1 (char 0) (Rancher) SAM local invoke failed: Expecting value: line 1 column 1 Aug 31, 2023
@stefanlduplessis
Copy link
Author

stefanlduplessis commented Sep 1, 2023

Looks like I missed a very important detail from aws/aws-sam-cli#3595 (comment):

If you are a Mac/Windows user:
If the Docker Desktop is not installed in MacOS or Windows, the following commands and options will not work:

  • sam build --use-container
  • sam build when you specify a Dockerfile and OCI Image as your packaging format
  • sam local invoke
  • sam local start-api
  • sam local start-lambda

which are all the command options I need for debugging lambdas locally.
So Rancher won't work. I will need to switch to either one of these:

  • macOS and Colima
  • Docker CLI and Docker Engine inside a virtual machine with Linux system

Thank you for the help @justinmk3

@justinmk3 justinmk3 added documentation guidance General information and guidance, answers to FAQs, or recommended best practices/resources. and removed bug We can reproduce the issue and confirmed it is a bug. needs-response Waiting on reply from issue/PR author. labels Sep 1, 2023
@justinmk3
Copy link
Contributor

Troubleshooting steps mentioned in aws/aws-sam-cli#5646 (comment) may be useful:

  1. Use docker context inspect to find the socket location
  2. Export DOCKER_HOST (and start vscode from the same terminal to ensure that it inherits the DOCKER_HOST environment variable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation guidance General information and guidance, answers to FAQs, or recommended best practices/resources. sam
Projects
None yet
Development

No branches or pull requests

2 participants