aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.49k stars 418 forks source link

Create Lambda SAM Application -> 'TypeError: $ is not iterable' #4057

Closed swarner1033 closed 9 months ago

swarner1033 commented 10 months ago

Problem

Files were generated as expected but error produced. Additionally, the vscode testing module failed with ModuleNotFoundError: No module named 'hello_world'. Unsure if this is related though.

Error output ``` 2023-11-17 18:12:54 [INFO]: log level: debug 2023-11-17 18:12:54 [DEBUG]: Logging started: file:///Users/sophiewarner/Library/Application%20Support/Code/logs/20231116T113204/window6/exthost/amazonwebservices.aws-toolkit-vscode/aws_toolkit_20231117T181254.log 2023-11-17 18:12:54 [INFO]: endpoints: retrieving AWS endpoints data 2023-11-17 18:12:54 [VERBOSE]: loading file resource: "/Users/sophiewarner/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.98.0/resources/endpoints.json" 2023-11-17 18:12:54 [INFO]: OS: Darwin x64 22.6.0 2023-11-17 18:12:54 [INFO]: Visual Studio Code extension host: 1.84.2 2023-11-17 18:12:54 [INFO]: AWS Toolkit: 1.98.0 2023-11-17 18:12:54 [INFO]: node: 18.15.0 2023-11-17 18:12:54 [INFO]: electron: 25.9.2 2023-11-17 18:12:54 [DEBUG]: firstStartup: This is not the users first use of the extension. Skipped showing Add Connections page. 2023-11-17 18:12:54 [VERBOSE]: Telemetry is now enabled 2023-11-17 18:12:54 [VERBOSE]: downloading: https://idetoolkits.amazonwebservices.com/endpoints.json 2023-11-17 18:12:54 [WARN]: AwsContext: no default region in credentials profile, falling back to us-east-1: 2023-11-17 18:12:54 [VERBOSE]: telemetry: emitted metric "session_start" 2023-11-17 18:12:54 [VERBOSE]: downloading: https://api.github.com/repos/devfile/api/releases/latest 2023-11-17 18:12:54 [VERBOSE]: codecatalyst: not a devenv, getThisDevEnv() returned empty 2023-11-17 18:12:54 [VERBOSE]: credentials: found sections: - treating as Process Credentials 2023-11-17 18:12:54 [DEBUG]: codewhisperer: Connection is valid = false, connection is undefined = true, secondaryAuth connection expired = false 2023-11-17 18:12:54 [DEBUG]: codewhisperer: Connection expired = false, secondaryAuth connection expired = false, connection is undefined = true 2023-11-17 18:12:54 [DEBUG]: codewhisperer: Connection is valid = false, connection is undefined = true, secondaryAuth connection expired = false 2023-11-17 18:12:54 [DEBUG]: codewhisperer: Connection expired = false, secondaryAuth connection expired = false, connection is undefined = true 2023-11-17 18:12:55 [VERBOSE]: credentials: EC2 metadata service unavailable: TimeoutError: Socket timed out without establishing a connection 2023-11-17 18:12:55 [VERBOSE]: credentials: EC2 metadata service call took 550ms 2023-11-17 18:12:55 [VERBOSE]: auth: "instance" provider unavailable 2023-11-17 18:12:55 [VERBOSE]: auth: "instance" provider unavailable 2023-11-17 18:12:55 [VERBOSE]: auth: "variables" provider unavailable 2023-11-17 18:12:55 [VERBOSE]: telemetry: emitted metric "aws_loadCredentials" 2023-11-17 18:12:55 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-11-17 18:12:55 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-11-17 18:12:55 [DEBUG]: codewhisperer: Connection is valid = false, connection is undefined = false, secondaryAuth connection expired = true 2023-11-17 18:12:55 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-11-17 18:12:55 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-11-17 18:12:55 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-11-17 18:12:55 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-11-17 18:12:55 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-11-17 18:12:55 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-11-17 18:12:55 [VERBOSE]: telemetry: emitted metric "vscode_activeRegions" 2023-11-17 18:12:55 [VERBOSE]: downloaded: https://idetoolkits.amazonwebservices.com/endpoints.json 2023-11-17 18:12:55 [VERBOSE]: Refreshing AWS Explorer due to Region Provider updates 2023-11-17 18:12:55 [VERBOSE]: loading file resource: "/Users/sophiewarner/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/sam.schema.json" 2023-11-17 18:12:55 [VERBOSE]: samCliLocator: searching in: /opt/homebrew/bin/sam 2023-11-17 18:12:55 [VERBOSE]: samCliLocator: searching in: /usr/local/bin/sam 2023-11-17 18:12:56 [VERBOSE]: E-Tag, W/"4cd051c0d58b065461bf0191c90d9aacd212b717e7e8990b964be946fa9f5f06", matched. No content downloaded from: https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json 2023-11-17 18:12:56 [VERBOSE]: telemetry: emitted metric "toolkit_getExternalResource" 2023-11-17 18:12:56 [VERBOSE]: loading file resource: "/Users/sophiewarner/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/sam.schema.json" 2023-11-17 18:12:57 [VERBOSE]: E-Tag, W/"4cd051c0d58b065461bf0191c90d9aacd212b717e7e8990b964be946fa9f5f06", matched. No content downloaded from: https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json 2023-11-17 18:12:57 [VERBOSE]: telemetry: emitted metric "toolkit_getExternalResource" 2023-11-17 18:12:57 [VERBOSE]: loading file resource: "/Users/sophiewarner/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/devfile.schema.json" 2023-11-17 18:12:57 [VERBOSE]: samCliLocator: getLocation took 1964ms 2023-11-17 18:12:57 [INFO]: SAM CLI location (version: 1.103.0): /usr/local/bin/sam 2023-11-17 18:12:59 [VERBOSE]: samCliLocator: getLocation took 1570ms 2023-11-17 18:13:01 [ERROR]: Error resuming SAM Application creation. Check the logs by running the "View AWS Toolkit Logs" command from the Command Palette. 2023-11-17 18:13:01 [ERROR]: Error resuming new SAM Application: 'TypeError: $ is not iterable' 2023-11-17 18:13:01 [VERBOSE]: telemetry: emitted metric "sam_init" 2023-11-17 18:13:02 [DEBUG]: Settings (aws.samcli): key "lambdaTimeout" changed 2023-11-17 18:13:02 [DEBUG]: Settings (aws.samcli): key "manuallySelectedBuckets" changed 2023-11-17 18:13:03 [DEBUG]: Settings (aws.samcli): key "lambdaTimeout" changed 2023-11-17 18:13:03 [DEBUG]: Settings (aws.samcli): key "manuallySelectedBuckets" changed 2023-11-17 18:13:03 [VERBOSE]: telemetry: emitted metric "toolkit_init" 2023-11-17 18:13:11 [DEBUG]: command: running "aws.viewLogs" 2023-11-17 18:13:11 [VERBOSE]: telemetry: emitted metric "toolkit_viewLogs" 2023-11-17 18:13:11 [VERBOSE]: telemetry: emitted metric "vscode_executeCommand" ```

Steps to reproduce the issue

  1. Follow these steps https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/sam-get-started.html with python3.11 and Hello World

Expected behavior

No errors shown

System details (run the AWS: About Toolkit command)

OS: Darwin x64 22.6.0 Visual Studio Code extension host: 1.84.2 AWS Toolkit: 1.98.0 node: 18.15.0 electron: 25.9.2

justinmk3 commented 10 months ago
2023-11-17 18:13:01 [ERROR]: Error resuming SAM Application creation. Check the logs by running the "View AWS Toolkit Logs" command from the Command Palette.
2023-11-17 18:13:01 [ERROR]: Error resuming new SAM Application: 'TypeError: $ is not iterable'

Thanks for the report. Can you try the prerelease build: https://github.com/aws/aws-toolkit-vscode/releases/tag/prerelease

swarner1033 commented 10 months ago

Hey, sorry for the delayed response. Got a similar error

Error output ``` 2023-12-06 14:42:59 [INFO]: log level: debug 2023-12-06 14:42:59 [DEBUG]: Logging started: file:///Users/sophiewarner/Library/Application%20Support/Code/logs/20231206T125433/window2/exthost/amazonwebservices.aws-toolkit-vscode/aws_toolkit_20231206T144259.log 2023-12-06 14:42:59 [INFO]: endpoints: retrieving AWS endpoints data 2023-12-06 14:42:59 [VERBOSE]: loading file resource: "/Users/sophiewarner/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-2.2.0-9a96e56/resources/endpoints.json" 2023-12-06 14:42:59 [INFO]: OS: Darwin x64 22.6.0 2023-12-06 14:42:59 [INFO]: Visual Studio Code extension host: 1.84.2 2023-12-06 14:42:59 [INFO]: AWS Toolkit: 2.2.0-9a96e56 2023-12-06 14:42:59 [INFO]: node: 18.15.0 2023-12-06 14:42:59 [INFO]: electron: 25.9.2 2023-12-06 14:42:59 [VERBOSE]: Telemetry is now enabled 2023-12-06 14:42:59 [VERBOSE]: downloading: https://idetoolkits.amazonwebservices.com/endpoints.json 2023-12-06 14:42:59 [WARN]: AwsContext: no default region in credentials profile, falling back to us-east-1: 2023-12-06 14:42:59 [DEBUG]: telemetry: emitted metric "session_start" -> {"Metadata":[{"Key":"awsAccount","Value":"n/a"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"session_start","Value":1,"Unit":"None","Passive":true,"EpochTimestamp":1701834179409} 2023-12-06 14:42:59 [DEBUG]: firstStartup: This is not the users first use of the extension. Skipped showing Add Connections page. 2023-12-06 14:42:59 [VERBOSE]: downloading: https://api.github.com/repos/devfile/api/releases/latest 2023-12-06 14:42:59 [VERBOSE]: credentials: found sections: 2023-12-06 14:42:59 [VERBOSE]: Profile aws-trex contains credential_process - treating as Process Credentials 2023-12-06 14:43:00 [VERBOSE]: downloaded: https://api.github.com/repos/devfile/api/releases/latest 2023-12-06 14:43:00 [VERBOSE]: loading file resource: "/Users/sophiewarner/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/sam.schema.json" 2023-12-06 14:43:00 [VERBOSE]: codecatalyst: not a devenv, getThisDevEnv() returned empty 2023-12-06 14:43:00 [DEBUG]: telemetry: emitted metric "vscode_activeRegions" -> {"Metadata":[{"Key":"awsAccount","Value":"not-set"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"vscode_activeRegions","Value":2,"Unit":"Count","Passive":true,"EpochTimestamp":1701834180711} 2023-12-06 14:43:02 [VERBOSE]: downloaded: https://idetoolkits.amazonwebservices.com/endpoints.json 2023-12-06 14:43:02 [VERBOSE]: Refreshing AWS Explorer due to Region Provider updates 2023-12-06 14:43:02 [VERBOSE]: credentials: EC2 metadata service unavailable: TimeoutError: Socket timed out without establishing a connection 2023-12-06 14:43:02 [VERBOSE]: credentials: EC2 metadata service call took 1340ms 2023-12-06 14:43:02 [VERBOSE]: auth: "instance" provider unavailable 2023-12-06 14:43:02 [VERBOSE]: auth: "instance" provider unavailable 2023-12-06 14:43:02 [VERBOSE]: auth: "variables" provider unavailable 2023-12-06 14:43:02 [DEBUG]: telemetry: emitted metric "aws_loadCredentials" -> {"Metadata":[{"Key":"credentialSourceId","Value":"sharedCredentials"},{"Key":"awsAccount","Value":"not-set"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"aws_loadCredentials","Value":289,"Unit":"Count","Passive":true,"EpochTimestamp":1701834182102} 2023-12-06 14:43:02 [DEBUG]: SSO token cache: read failed (file not found) key: a526092f-5195-4143-9695-1b23fd0377f0 2023-12-06 14:43:02 [DEBUG]: codewhisperer: Connection is valid = false, connection is undefined = false, secondaryAuth connection expired = true 2023-12-06 14:43:02 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-12-06 14:43:02 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-12-06 14:43:02 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-12-06 14:43:02 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-12-06 14:43:02 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-12-06 14:43:02 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-12-06 14:43:02 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-12-06 14:43:02 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-12-06 14:43:02 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-12-06 14:43:02 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-12-06 14:43:02 [VERBOSE]: E-Tag, W/"80807845f2b596bc3de1c2e9b9d21e6d709e3af98d632a2b7825e856feadeba7", matched. No content downloaded from: https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json 2023-12-06 14:43:02 [DEBUG]: telemetry: emitted metric "toolkit_getExternalResource" -> {"Metadata":[{"Key":"url","Value":"https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json"},{"Key":"result","Value":"Cancelled"},{"Key":"reason","Value":"Cache hit"},{"Key":"awsAccount","Value":"not-set"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"toolkit_getExternalResource","Value":1,"Unit":"None","Passive":true,"EpochTimestamp":1701834182706} 2023-12-06 14:43:02 [VERBOSE]: loading file resource: "/Users/sophiewarner/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/sam.schema.json" 2023-12-06 14:43:02 [VERBOSE]: samCliLocator: searching in: /opt/homebrew/bin/sam 2023-12-06 14:43:02 [VERBOSE]: samCliLocator: searching in: /usr/local/bin/sam 2023-12-06 14:43:03 [VERBOSE]: E-Tag, W/"80807845f2b596bc3de1c2e9b9d21e6d709e3af98d632a2b7825e856feadeba7", matched. No content downloaded from: https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json 2023-12-06 14:43:03 [DEBUG]: telemetry: emitted metric "toolkit_getExternalResource" -> {"Metadata":[{"Key":"url","Value":"https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json"},{"Key":"result","Value":"Cancelled"},{"Key":"reason","Value":"Cache hit"},{"Key":"awsAccount","Value":"not-set"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"toolkit_getExternalResource","Value":1,"Unit":"None","Passive":true,"EpochTimestamp":1701834183321} 2023-12-06 14:43:03 [VERBOSE]: loading file resource: "/Users/sophiewarner/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/devfile.schema.json" 2023-12-06 14:43:03 [VERBOSE]: samCliLocator: getLocation took 932ms 2023-12-06 14:43:03 [INFO]: SAM CLI location (version: 1.103.0): /usr/local/bin/sam 2023-12-06 14:43:04 [VERBOSE]: samCliLocator: getLocation took 446ms 2023-12-06 14:43:05 [ERROR]: Error resuming SAM Application creation. Check the logs by running the "View AWS Toolkit Logs" command from the Command Palette. 2023-12-06 14:43:05 [ERROR]: Error resuming new SAM Application: 'TypeError: V is not iterable' 2023-12-06 14:43:05 [DEBUG]: telemetry: emitted metric "sam_init" -> {"Metadata":[{"Key":"lambdaPackageType","Value":"Zip"},{"Key":"result","Value":"Failed"},{"Key":"reason","Value":"error"},{"Key":"runtime","Value":"python3.11"},{"Key":"version","Value":"1.103.0"},{"Key":"awsAccount","Value":"not-set"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"sam_init","Value":1,"Unit":"None","Passive":false,"EpochTimestamp":1701834185129} 2023-12-06 14:43:05 [DEBUG]: SSO token cache: read failed (file not found) key: a526092f-5195-4143-9695-1b23fd0377f0 2023-12-06 14:43:05 [DEBUG]: codewhisperer: Connection expired = true, secondaryAuth connection expired = true, connection is undefined = false 2023-12-06 14:43:05 [DEBUG]: codewhisperer: isValidCodeWhispererConnection = true 2023-12-06 14:43:05 [DEBUG]: Settings (aws.samcli): key "manuallySelectedBuckets" changed 2023-12-06 14:43:05 [DEBUG]: Settings (aws.samcli): key "manuallySelectedBuckets" changed 2023-12-06 14:43:05 [DEBUG]: telemetry: emitted metric "toolkit_init" -> {"Metadata":[{"Key":"duration","Value":"6337"},{"Key":"awsAccount","Value":"not-set"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"toolkit_init","Value":1,"Unit":"None","Passive":true,"EpochTimestamp":1701834185633} 2023-12-06 14:43:24 [DEBUG]: command: running "aws.viewLogs" 2023-12-06 14:43:24 [DEBUG]: telemetry: emitted metric "toolkit_viewLogs" -> {"Metadata":[{"Key":"parentMetric","Value":"vscode_executeCommand"},{"Key":"awsAccount","Value":"not-set"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"toolkit_viewLogs","Value":1,"Unit":"None","Passive":false,"EpochTimestamp":1701834204073} 2023-12-06 14:43:24 [DEBUG]: telemetry: emitted metric "vscode_executeCommand" -> {"Metadata":[{"Key":"command","Value":"aws.viewLogs"},{"Key":"duration","Value":"70"},{"Key":"result","Value":"Succeeded"},{"Key":"awsAccount","Value":"not-set"},{"Key":"awsRegion","Value":"us-east-1"}],"MetricName":"vscode_executeCommand","Value":1,"Unit":"None","Passive":true,"EpochTimestamp":1701834204072} ```
justinmk3 commented 10 months ago
2023-12-06 14:43:05 [ERROR]: Error resuming SAM Application creation. Check the logs by running the "View AWS Toolkit Logs" command from the Command Palette.
2023-12-06 14:43:05 [ERROR]: Error resuming new SAM Application: 'TypeError: V is not iterable'

That comes from: https://github.com/aws/aws-toolkit-vscode/blob/af655f604ffc8fa99a49a901636dd270175b5c2e/src/lambda/commands/createNewSamApp.ts#L106

This indicates that something in provideDebugConfigurations is failing.

https://github.com/aws/aws-toolkit-vscode/blob/af655f604ffc8fa99a49a901636dd270175b5c2e/src/lambda/commands/createNewSamApp.ts#L392

https://github.com/aws/aws-toolkit-vscode/blob/af655f604ffc8fa99a49a901636dd270175b5c2e/src/shared/sam/debugger/awsSamDebugger.ts#L246

Status

We need to improve the "shape checks" and logging in addInitialLaunchConfiguration and provideDebugConfigurations.

bryceitoc9 commented 10 months ago

Looks like I can get a repro (might not be exactly the same) if I'm creating a new SAM app from a VS Code window not tied to a workspace/workspace folder (error happens when we open a workspace folder and attempt to resume).

bryceitoc9 commented 10 months ago

@swarner1033 If you're consistently reproing, can you try downloading the VSIX in https://d1ihu6zq92vp9p.cloudfront.net/02dc9fba-112a-4f37-9ec5-c681a5126678/report.html (get the primary artifact and unzip it)? This comes from https://github.com/aws/aws-toolkit-vscode/pull/4151

justinmk3 commented 9 months ago

AWS Toolkit 2.3.0 includes a fix for this.