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

sam build AttributeError #6225

Closed
pickfire opened this issue Nov 8, 2023 · 4 comments
Closed

sam build AttributeError #6225

pickfire opened this issue Nov 8, 2023 · 4 comments
Labels
blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced

Comments

@pickfire
Copy link

pickfire commented Nov 8, 2023

Description:

AttributeError when sam build

Steps to reproduce:

sam build -u

Observed result:

2023-11-08 17:19:22,238 | Config file location: /Users/ivan/pantas-infra/samconfig.toml                                                                                                          
2023-11-08 17:19:22,241 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file at '/Users/ivan/pantas-infra/samconfig.toml'...             
2023-11-08 17:19:22,242 | Configuration values successfully loaded.                                                                                                                              
2023-11-08 17:19:22,242 | Configuration values are: {}                                                                                                                                           
2023-11-08 17:19:22,257 | Using SAM Template at /Users/ivan/pantas-infra/template.yaml                                                                                                           
2023-11-08 17:19:22,283 | Using config file: samconfig.toml, config environment: default                                                                                                         
2023-11-08 17:19:22,283 | Expand command line arguments to:                                                                                                                                      
2023-11-08 17:19:22,284 | --template_file=/Users/ivan/pantas-infra/template.yaml --use_container --mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache                         
2023-11-08 17:19:22,379 | 'build' command is called                                                                                                                                              
2023-11-08 17:19:22,379 | Starting Build inside a container                                                                                                                                      
2023-11-08 17:19:22,394 | Collected default values for parameters: {}                                                                                                                            
2023-11-08 17:19:22,414 | There is no customer defined id or cdk path defined for resource xxx, so we will use the resource logical id as the resource id                              
...
2023-11-08 17:19:22,418 | There is no customer defined id or cdk path defined for resource xxx, so we will use the resource logical id as the resource id                                 
2023-11-08 17:19:22,420 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                                             
2023-11-08 17:19:22,458 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                                             
2023-11-08 17:19:22,459 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '7b3c609f-d7b0-480a-b4b8-1c0f525cabb5', 'installationId': '204703a9-cc97-473c-9255-c5e9e2355e54',         
'sessionId': '8d3b2373-883c-409d-ad4f-90fd4a61104a', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.12.0', 'samcliVersion': '1.100.0', 'awsProfileProvided': False,                 
'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName':                                        
'67aab61105387da9a19ab6fdbfee5482870508ce9656fcbbeb51acc7f71792df', 'initialCommit': None}, 'duration': 137, 'exitReason': 'AttributeError', 'exitCode': 255}}]}                                 
2023-11-08 17:19:22,459 | Unable to find Click Context for getting session_id.                                                                                                                   
2023-11-08 17:19:22,463 | Sending Telemetry: {'metrics': [{'events': {'requestId': 'f66ff866-b830-4cc9-818b-6e1658fab0c5', 'installationId': '204703a9-cc97-473c-9255-c5e9e2355e54', 'sessionId':
'8d3b2373-883c-409d-ad4f-90fd4a61104a', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.12.0', 'samcliVersion': '1.100.0', 'commandName': 'sam build', 'metricSpecificAttributes':   
{'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '85210a35b77b4cfba982ff0d5e225621', 'time_stamp': '2023-11-08 09:19:22.238', 'exception_name': None},  
{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': 'ad9a30f2e4584031a0acc59341714cce', 'time_stamp': '2023-11-08 09:19:22.282', 'exception_name': None}]}}}]}         
2023-11-08 17:19:23,312 | 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 "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/cli/cli_config_file.py", line 347, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 184, in wrapped
    raise exception  # pylint: disable=raising-bad-type
    ^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 149, in wrapped
    return_value = func(*args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/lib/utils/version_checker.py", line 42, in wrapped
    actual_result = func(*args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/cli/main.py", line 95, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/commands/build/command.py", line 171, in cli
    do_cli(
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/commands/build/command.py", line 236, in do_cli
    with BuildContext(
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/commands/build/build_context.py", line 184, in __enter__
    self.set_up()
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/commands/build/build_context.py", line 190, in set_up
    self._stacks, remote_stack_full_paths = SamLocalStackProvider.get_stacks(
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/lib/providers/sam_stack_provider.py", line 269, in get_stacks
    current = SamLocalStackProvider(
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/lib/providers/sam_stack_provider.py", line 73, in __init__
    self._extract_stacks()
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/lib/providers/sam_stack_provider.py", line 126, in _extract_stacks
    stack = SamLocalStackProvider._convert_cfn_stack_resource(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/lib/providers/sam_stack_provider.py", line 185, in _convert_cfn_stack_resource
    if SamLocalStackProvider.is_remote_url(template_url):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.100.0/libexec/lib/python3.12/site-packages/samcli/lib/providers/sam_stack_provider.py", line 296, in is_remote_url
    return any([url.startswith(prefix) for prefix in ["s3://", "http://", "https://"]])
                ^^^^^^^^^^^^^^

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

Expected result:

Build should work.

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

  1. OS: macos
  2. sam --version: 1.100.0
  3. AWS region: ap-southeast-1
{
  "version": "1.100.0",
  "system": {
    "python": "3.12.0",
    "os": "macOS-14.0-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "20.10.17",
    "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"
  ]
}

Most likely caused by this

    Type: AWS::CloudFormation::Stack
    Properties:
      Parameters:
        TemplateBody: file://template.yaml
@pickfire pickfire added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Nov 8, 2023
@hawflau
Copy link
Contributor

hawflau commented Nov 8, 2023

Hi @pickfire thanks for raising the issue. Could you please provide your template to help reproduce the error?

@hawflau hawflau added blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 8, 2023
@pickfire
Copy link
Author

Sorry, I lost the template.

@hnnasit
Copy link
Contributor

hnnasit commented Jul 30, 2024

Closing the issue as it's no longer active and cannot be re-produced. There is not enough info for us to reproduce. Please open a new issue if you still run into issues with steps to reproduce for us to investigate further.

@hnnasit hnnasit closed this as completed Jul 30, 2024
Copy link
Contributor

⚠️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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced
Projects
None yet
Development

No branches or pull requests

3 participants