A sam template that contains AWS::CloudFormation::Stack instead of AWS::Serverless::Application will report an "Error: 'NoneType' object has no attribute 'startswith'" along with traceback.
template1.yml is a valid SAM Template. This is according to basic SAM Validation, for additional validation, please run with "--lint" option
$ sam deploy --stack-name bugdemo --template-file .aws/cloudformation/template1.yml --resolve-s3 --debug
2024-11-17 18:35:12,618 | No config file found in this directory.
2024-11-17 18:35:12,631 | OSError occurred while reading TOML file: [Errno 2] No such file or directory:
'/samconfig.toml'
2024-11-17 18:35:12,636 | Config file location: /samconfig.toml
2024-11-17 18:35:12,639 | Config file '/samconfig.toml' does not exist
2024-11-17 18:35:12,748 | OSError occurred while reading TOML file: [Errno 2] No such file or directory:
'/samconfig.toml'
2024-11-17 18:35:12,757 | Using config file: samconfig.toml, config environment: default
2024-11-17 18:35:12,760 | Expand command line arguments to:
2024-11-17 18:35:12,762 | --template_file=/template1.yml --stack_name=bugdemo --resolve_s3
--fail_on_empty_changeset --on_failure=ROLLBACK --max_wait_duration=60
Managed S3 bucket: aws-sam-cli-managed-default-samclisourcebucket-abc123
A different default S3 bucket can be set in samconfig.toml
Or by specifying --s3-bucket explicitly.
2024-11-17 18:35:14,463 | No Parameters detected in the template
2024-11-17 18:35:14,514 | There is no customer defined id or cdk path defined for resource Template2Stack, so we will use the resource logical id as the
resource id
2024-11-17 18:35:14,517 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2024-11-17 18:35:14,538 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2024-11-17 18:35:14,540 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '72b67a77-858e-43e3-baf0-d6027cd599ff', 'installationId':
'78c6a692-3676-4792-bc20-472253a5706e', 'sessionId': 'eda34860-d3ef-4ea0-aa0f-8584baa5b944', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion':
'3.11.10', 'samcliVersion': '1.129.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam deploy',
'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '71b4dc3997f9e2c486dcdaa005d97394657b14c6a4f62d277dc01722f53cf4c0',
'initialCommit': None}, 'duration': 1759, 'exitReason': 'AttributeError', 'exitCode': 255}}]}
2024-11-17 18:35:14,540 | Unable to find Click Context for getting session_id.
2024-11-17 18:35:14,547 | Sending Telemetry: {'metrics': [{'events': {'requestId': '3440ae60-4836-40fe-84c6-5675315c8a24', 'installationId':
'78c6a692-3676-4792-bc20-472253a5706e', 'sessionId': 'eda34860-d3ef-4ea0-aa0f-8584baa5b944', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion':
'3.11.10', 'samcliVersion': '1.129.0', 'commandName': 'sam deploy', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension',
'event_value': '.toml', 'thread_id': '5086384978924849b600179af2ce3d03', 'time_stamp': '2024-11-17 18:35:12.635', 'exception_name': None},
{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': 'e2a987ce35924bd79b206b6d574e0805', 'time_stamp': '2024-11-17
18:35:12.752', 'exception_name': None}]}}}]}
2024-11-17 18:35:20,456 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read
timeout=0.1)
Error: 'NoneType' object has no attribute 'startswith'
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 "samcli/cli/cli_config_file.py", line 347, in wrapper
File "samcli/lib/cli_validation/image_repository_validation.py", line 111, in wrapped
File "click/decorators.py", line 92, in new_func
File "click/core.py", line 783, in invoke
File "samcli/lib/telemetry/metric.py", line 185, in wrapped
File "samcli/lib/telemetry/metric.py", line 150, in wrapped
File "samcli/lib/utils/version_checker.py", line 43, in wrapped
File "samcli/cli/main.py", line 95, in wrapper
File "samcli/commands/_utils/cdk_support_decorators.py", line 40, in wrapped
File "samcli/commands/_utils/command_exception_handler.py", line 89, in wrapper_command_exception_handler
File "samcli/commands/_utils/command_exception_handler.py", line 69, in wrapper_command_exception_handler
File "samcli/commands/deploy/command.py", line 208, in cli
File "samcli/commands/deploy/command.py", line 344, in do_cli
File "samcli/commands/package/package_context.py", line 106, in run
File "samcli/lib/providers/sam_stack_provider.py", line 270, in get_stacks
File "samcli/lib/providers/sam_stack_provider.py", line 74, in init
File "samcli/lib/providers/sam_stack_provider.py", line 127, in _extract_stacks
File "samcli/lib/providers/sam_stack_provider.py", line 186, in _convert_cfn_stack_resource
File "samcli/lib/providers/sam_stack_provider.py", line 297, in is_remote_url
File "samcli/lib/providers/sam_stack_provider.py", line 297, in
Description:
A sam template that contains
AWS::CloudFormation::Stack
instead ofAWS::Serverless::Application
will report an "Error: 'NoneType' object has no attribute 'startswith'" along with traceback.Possibly related to https://github.com/aws/aws-sam-cli/issues/6225.
Steps to reproduce:
# template1.yml
# template2.yml
Observed result:
Expected result:
Expect the template to fail validation, or the output to be more meaningful.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)