Publisher: Edge case fixes (#5165)

* do not crash whole controller because of invalid exception

* handle missing instance label

* fix also list view
This commit is contained in:
Jakub Trllo 2023-06-23 16:11:23 +02:00 committed by GitHub
parent 23fe05dbf8
commit 3ffef444ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View file

@ -398,12 +398,22 @@ class PublishReportMaker:
exception = result.get("error")
if exception:
fname, line_no, func, exc = exception.traceback
# Conversion of exception into string may crash
try:
msg = str(exception)
except BaseException:
msg = (
"Publisher Controller: ERROR"
" - Failed to get exception message"
)
# Action result does not have 'is_validation_error'
is_validation_error = result.get("is_validation_error", False)
output.append({
"type": "error",
"is_validation_error": is_validation_error,
"msg": str(exception),
"msg": msg,
"filename": str(fname),
"lineno": str(line_no),
"func": str(func),

View file

@ -45,8 +45,13 @@ class InstancesModel(QtGui.QStandardItemModel):
instance_items = report_item.instance_items_by_family[family]
all_removed = True
for instance_item in instance_items:
item = QtGui.QStandardItem(instance_item.label)
instance_label = html_escape(instance_item.label)
src_instance_label = instance_item.label
if src_instance_label is None:
# Do not cause UI crash if label is 'None'
src_instance_label = "No label"
instance_label = html_escape(src_instance_label)
item = QtGui.QStandardItem(src_instance_label)
item.setData(instance_label, ITEM_LABEL_ROLE)
item.setData(instance_item.errored, ITEM_ERRORED_ROLE)
item.setData(instance_item.id, ITEM_ID_ROLE)

View file

@ -116,7 +116,12 @@ class InstanceListItemWidget(QtWidgets.QWidget):
self.instance = instance
instance_label = html_escape(instance.label)
instance_label = instance.label
if instance_label is None:
# Do not cause UI crash if label is 'None'
instance_label = "No label"
instance_label = html_escape(instance_label)
subset_name_label = QtWidgets.QLabel(instance_label, self)
subset_name_label.setObjectName("ListViewSubsetName")