-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Description:
When I ran sam build --debug for a template.yaml with a Serverless::LayerVersion, it showed this error (along with other, non-important details) then failed to build:
--- Logging error ---
Traceback (most recent call last):
File "/var/lang/lib/python3.8/logging/__init__.py", line 1081, in emit
msg = self.format(record)
File "/var/lang/lib/python3.8/logging/__init__.py", line 925, in format
return fmt.format(record)
File "/var/lang/lib/python3.8/logging/__init__.py", line 664, in format
record.message = record.getMessage()
File "/var/lang/lib/python3.8/logging/__init__.py", line 369, in getMessage
msg = msg % self.args
File "/var/lang/lib/python3.8/site-packages/samcli/lib/build/build_graph.py", line 353, in __str__
f"LayerBuildDefinition({self.name}, {self.codeuri}, {self.source_md5}, {self.uuid}, "
AttributeError: 'NoneType' object has no attribute 'name'Steps to reproduce:
sam initand choose the following:
- 1 - AWS Quick Start Templates
- 1 - Zip
- 2 - python3.8
- 1 - Hello World Example
- Edit
template.yamlto add this to thePropertiesofHelloWorldFunction:
Layers:
- !Ref MyLayer
- Add this to
template.yaml:
MyLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: test-layer
ContentUri: my_layer
CompatibleRuntimes:
- python3.8
Metadata:
BuildMethod: python3.8
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Windows 10 and Linux
sam --version: SAM CLI, version 1.18.2 and 1.19.1 and 1.20.0
Proposed fix
It appears the problem is that LayerBuildDefinition.__str__() tries to print self.layer.name, but self.layer is None, so I just changed self.layer.name in the f string to this: self.layer.name if self.layer else None
Reactions are currently unavailable