aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.49k stars 1.17k forks source link

Bug: sam delete raising error #6492

Closed Thomas-McKanna closed 8 months ago

Thomas-McKanna commented 8 months ago

Description:

Periodically, I get an error when trying to delete my SAM application. I don't know what conditions cause it, unfortunately, but I've pasted my traceback below.

There was a similar issue in the past the got closed (https://github.com/aws/aws-sam-cli/issues/5955), but it seems this is still an issue.

Steps to reproduce:

Run sam delete. The issue is flakey, and sometimes I am able to delete my SAM apps.

Observed result:

2023-12-26 21:49:06,695 | Using config file: samconfig.toml, config environment: default                      
2023-12-26 21:49:06,699 | Expand command line arguments to:                                                   
2023-12-26 21:49:06,702 |                                                                                     
2023-12-26 21:49:07,066 | Config file location: /home/ubuntu/foobar/ingest/samconfig.toml                  
2023-12-26 21:49:07,069 | Loading configuration values from [default.['deploy'].parameters]                   
(env.command_name.section) in config file at '/home/ubuntu/foobar/ingest/samconfig.toml'...                
2023-12-26 21:49:07,072 | Configuration values successfully loaded.                                           
2023-12-26 21:49:07,073 | Configuration values are: {'stack_name': 'foobar-ingest', 'capabilities':        
'CAPABILITY_IAM', 'confirm_changeset': True, 'resolve_s3': True}                                              
2023-12-26 21:49:07,077 | Local config present and using the defined options                                  
        Are you sure you want to delete the stack foobar-ingest in the region us-east-2 ? [y/N]: y
2023-12-26 21:49:10,542 | Input stack is deployed, continue deleting                                          
2023-12-26 21:49:10,598 | Telemetry endpoint configured to be                                                 
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                        
2023-12-26 21:49:10,611 | Telemetry endpoint configured to be                                                 
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                        
2023-12-26 21:49:10,612 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId':                        
'f563db03-37e3-448e-818d-c4b3b4d3942c', 'installationId': 'df494611-6e0c-47d3-9264-c37ec17d513c', 'sessionId':
'f5bca03d-da13-420c-bb20-50fa62c6836d', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.3',    
'samcliVersion': '1.97.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '',              
'commandName': 'sam delete', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None,            
'projectName': '6eb7f2ea8ffbb37f44d41bdc3382d193c3de752f89d5bafe7b85afc93a65c32b', 'initialCommit': None},    
'duration': 3903, 'exitReason': 'TypeError', 'exitCode': 255}}]}                                              
2023-12-26 21:49:10,612 | Unable to find Click Context for getting session_id.                                
2023-12-26 21:49:10,618 | Sending Telemetry: {'metrics': [{'events': {'requestId':                            
'8641252b-36aa-46d8-bd97-2e86b7977785', 'installationId': 'df494611-6e0c-47d3-9264-c37ec17d513c', 'sessionId':
'f5bca03d-da13-420c-bb20-50fa62c6836d', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.3',    
'samcliVersion': '1.97.0', 'commandName': 'sam delete', 'metricSpecificAttributes': {'events': [{'event_name':
'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '6b1b50c406a847dca618bfb7a0fd608b',            
'time_stamp': '2023-12-26 21:49:07.066', 'exception_name': None}]}}}]}                                        
2023-12-26 21:49:10,814 | Telemetry response: 200                                                             

Error: string indices must be integers, not 'str'
Traceback:
  File "click/core.py", line 1078, in main
  File "click/core.py", line 1688, in invoke
  File "click/core.py", line 1434, in invoke
  File "click/core.py", line 783, in invoke
  File "click/decorators.py", line 92, in new_func
  File "click/core.py", line 783, in invoke
  File "samcli/lib/telemetry/metric.py", line 184, in wrapped
  File "samcli/lib/telemetry/metric.py", line 149, in wrapped
  File "samcli/lib/utils/version_checker.py", line 42, in wrapped
  File "samcli/cli/main.py", line 95, in wrapper
  File "samcli/commands/_utils/command_exception_handler.py", line 88, in wrapper_command_exception_handler
  File "samcli/commands/_utils/command_exception_handler.py", line 68, in wrapper_command_exception_handler
  File "samcli/commands/delete/command.py", line 96, in cli
  File "samcli/commands/delete/command.py", line 133, in do_cli
  File "samcli/commands/delete/delete_context.py", line 347, in run
  File "samcli/commands/delete/delete_context.py", line 275, in delete
  File "samcli/lib/package/artifact_exporter.py", line 353, in get_s3_info
  File "samcli/lib/package/artifact_exporter.py", line 252, in _apply_global_values

An unexpected error was encountered while executing "sam delete".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20delete%20-%20TypeError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20delete%20-%20TypeError
2023-12-26 21:49:10,822 | Telemetry response: 200

Expected result:

Successful deletion

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

OS:Linux Region: us-east-2

{
  "version": "1.97.0",
  "system": {
    "python": "3.11.3",
    "os": "Linux-6.2.0-1017-aws-x86_64-with-glibc2.35"
  },
  "additional_dependencies": {
    "docker_engine": "24.0.6",
    "aws_cdk": "Not available",
    "terraform": "1.6.2"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
hawflau commented 8 months ago

Hi @Thomas-McKanna, thanks for raising the issue. It seems you are using SAM CLI v1.97.0. Can you please upgrade your SAM CLI to v1.99.0 or above? as this comment mentions the fix was released in v1.99.0

Thomas-McKanna commented 8 months ago

Good call. Closing issue.

github-actions[bot] commented 8 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.