From 3ffef444ba3d7cabc34dc47b066edc9d20f6d805 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 23 Jun 2023 16:11:23 +0200 Subject: [PATCH] Publisher: Edge case fixes (#5165) * do not crash whole controller because of invalid exception * handle missing instance label * fix also list view --- openpype/tools/publisher/control.py | 12 +++++++++++- .../tools/publisher/publish_report_viewer/model.py | 9 +++++++-- .../tools/publisher/widgets/list_view_widgets.py | 7 ++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/openpype/tools/publisher/control.py b/openpype/tools/publisher/control.py index 89c2343ef7..502e871edd 100644 --- a/openpype/tools/publisher/control.py +++ b/openpype/tools/publisher/control.py @@ -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), diff --git a/openpype/tools/publisher/publish_report_viewer/model.py b/openpype/tools/publisher/publish_report_viewer/model.py index ff10e091b8..663a67ac70 100644 --- a/openpype/tools/publisher/publish_report_viewer/model.py +++ b/openpype/tools/publisher/publish_report_viewer/model.py @@ -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) diff --git a/openpype/tools/publisher/widgets/list_view_widgets.py b/openpype/tools/publisher/widgets/list_view_widgets.py index 557e6559c8..3370f71701 100644 --- a/openpype/tools/publisher/widgets/list_view_widgets.py +++ b/openpype/tools/publisher/widgets/list_view_widgets.py @@ -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")