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

Bug: sam deploy - AttributeError #7692

Open
powlo opened this issue Nov 17, 2024 · 1 comment
Open

Bug: sam deploy - AttributeError #7692

powlo opened this issue Nov 17, 2024 · 1 comment
Labels

Comments

@powlo
Copy link

powlo commented Nov 17, 2024

Description:

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.

Possibly related to #6225.

Steps to reproduce:

# template1.yml

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Resources:

  Template2Stack:
    Type: AWS::CloudFormation::Stack
    Properties:
      Location: template2.yml

# template2.yml

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Resources:
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.192.0.0/16
      EnableDnsSupport: true
      EnableDnsHostnames: true

Observed result:

$ sam validate --template-file template1.yml

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

An unexpected error was encountered while executing "sam deploy".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20deploy%20-%20AttributeError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20deploy%20-%20AttributeError

Expected result:

Expect the template to fail validation, or the output to be more meaningful.

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

{
  "version": "1.129.0",
  "system": {
    "python": "3.11.10",
    "os": "Linux-6.8.0-48-generic-x86_64-with-glibc2.39"
  },
  "additional_dependencies": {
    "docker_engine": "27.3.1",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "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"
  ]
}
@powlo powlo added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Nov 17, 2024
@dkphm
Copy link
Contributor

dkphm commented Nov 20, 2024

Thanks for reporting the issue. I was able to reproduce and we will fix in upcoming releases.

@dkphm dkphm added type/bug and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants