Skip to content

Commit 3dc7b29

Browse files
committed
Restore old behavior when display label only computes null values
1 parent 08b3475 commit 3dc7b29

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

backend/infrahub/core/node/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,15 @@ async def add_human_friendly_id(self, db: InfrahubDatabase) -> None:
210210
await self._human_friendly_id.compute(db=db, node=self)
211211

212212
async def get_display_label(self, db: InfrahubDatabase) -> str:
213-
if not self._display_label and self._schema.display_label:
214-
await self.add_display_label(db=db)
215-
216213
if self._display_label and (value := self._display_label.get_value(node=self, at=self._at)):
217214
return value
218215

219-
return repr(self)
216+
if not self._schema.display_label:
217+
return repr(self)
218+
219+
display_label = DisplayLabel(node_schema=self._schema, template=self._schema.display_label)
220+
await display_label.compute(db=db, node=self)
221+
return display_label.get_value(node=self, at=self._at) or ""
220222

221223
def has_display_label(self) -> bool:
222224
return self._display_label is not None

backend/infrahub/core/node/node_property_attribute.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ async def compute(self, db: InfrahubDatabase, node: Node) -> None:
150150

151151
if not self.is_jinja2_template:
152152
path_value = await node.get_path_value(db=db, path=self.template)
153-
# Use .value for enum to keep compat with old style display label
154-
self.set_value(value=str(path_value if not isinstance(path_value, Enum) else path_value.value))
153+
if path_value is not None:
154+
# Use .value for enum to keep compat with old style display label
155+
self.set_value(value=str(path_value if not isinstance(path_value, Enum) else path_value.value))
155156
return
156157

157158
jinja2_template = InfrahubJinja2Template(template=self.template)

0 commit comments

Comments
 (0)