From eca57b03d62393637956edb3ef573bcfefd80e7b Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 23 Feb 2022 10:36:38 +0100 Subject: [PATCH 1/2] OP-2736 - fail gracefully if slack exception --- .../modules/slack/plugins/publish/integrate_slack_api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openpype/modules/slack/plugins/publish/integrate_slack_api.py b/openpype/modules/slack/plugins/publish/integrate_slack_api.py index 5d014382a35..5b504ca3c79 100644 --- a/openpype/modules/slack/plugins/publish/integrate_slack_api.py +++ b/openpype/modules/slack/plugins/publish/integrate_slack_api.py @@ -60,6 +60,9 @@ def process(self, instance): message, publish_files) + if not msg_id: + return + msg = { "type": "slack", "msg_id": msg_id, @@ -177,6 +180,8 @@ def _python2_call(self, token, channel, message, publish_files): error_str = self._enrich_error(str(e), channel) self.log.warning("Error happened: {}".format(error_str)) + return None, [] + def _python3_call(self, token, channel, message, publish_files): from slack_sdk import WebClient from slack_sdk.errors import SlackApiError @@ -206,6 +211,8 @@ def _python3_call(self, token, channel, message, publish_files): error_str = self._enrich_error(str(e.response["error"]), channel) self.log.warning("Error happened {}".format(error_str)) + return None, [] + def _enrich_error(self, error_str, channel): """Enhance known errors with more helpful notations.""" if 'not_in_channel' in error_str: From 7f5185b217312e06188091831ec3b6f2f8306f2b Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 23 Feb 2022 13:24:55 +0100 Subject: [PATCH 2/2] OP-2736 - safer way to get paths Instances without any representations (for example when sending to render to farm) would fail with incorrect settings. --- openpype/modules/slack/plugins/publish/integrate_slack_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/modules/slack/plugins/publish/integrate_slack_api.py b/openpype/modules/slack/plugins/publish/integrate_slack_api.py index 5b504ca3c79..018a7594bbf 100644 --- a/openpype/modules/slack/plugins/publish/integrate_slack_api.py +++ b/openpype/modules/slack/plugins/publish/integrate_slack_api.py @@ -121,7 +121,7 @@ def _get_filled_message(self, message_templ, instance, review_path=None): def _get_thumbnail_path(self, instance): """Returns abs url for thumbnail if present in instance repres""" published_path = None - for repre in instance.data['representations']: + for repre in instance.data.get("representations", []): if repre.get('thumbnail') or "thumbnail" in repre.get('tags', []): if os.path.exists(repre["published_path"]): published_path = repre["published_path"] @@ -131,7 +131,7 @@ def _get_thumbnail_path(self, instance): def _get_review_path(self, instance): """Returns abs url for review if present in instance repres""" published_path = None - for repre in instance.data['representations']: + for repre in instance.data.get("representations", []): tags = repre.get('tags', []) if (repre.get("review") or "review" in tags