Protection against None values
We default project, version and build to None,
but in some parts we assume there aren't None.
@@ -481,7 +481,7 @@ class BaseEnvironment:
log.warning(
LOG_TEMPLATE,
{
- 'project': self.project.slug,
+ 'project': self.project.slug if self.project else '',
'version': 'latest',
'msg': msg,
}
@@ -570,8 +570,8 @@ class BuildEnvironment(BaseEnvironment):
log.info(
LOG_TEMPLATE,
{
- 'project': self.project.slug,
- 'version': self.version.slug,
+ 'project': self.project.slug if self.project else '',
+ 'version': self.version.slug if self.version else '',
'msg': 'Build finished',
}
)
@@ -614,9 +614,9 @@ class BuildEnvironment(BaseEnvironment):
extra={
'stack': True,
'tags': {
- 'build': self.build.get('id'),
- 'project': self.project.slug,
- 'version': self.version.slug,
+ 'build': self.build.get('id') if self.build else '',
+ 'project': self.project.slug if self.project else '',
+ 'version': self.version.slug if self.version else '',
},
},
)
