From 285ad4cdb3d9282df909d71e55714341cd4146f6 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 8 Jul 2024 19:59:33 +0200 Subject: [PATCH] Ignore invalid representation ids --- ...collect_input_representations_to_versions.py | 17 +++++++++++++++++ .../publish/collect_scene_loaded_versions.py | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py b/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py index 770f3470c6..009acba89c 100644 --- a/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py +++ b/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py @@ -1,7 +1,18 @@ +import uuid + import ayon_api import pyblish.api +def is_valid_uuid(value) -> bool: + """Return whether value is a valid UUID""" + try: + uuid.UUID(value) + except ValueError: + return False + return True + + class CollectInputRepresentationsToVersions(pyblish.api.ContextPlugin): """Converts collected input representations to input versions. @@ -23,6 +34,12 @@ class CollectInputRepresentationsToVersions(pyblish.api.ContextPlugin): if inst_repre: representations.update(inst_repre) + # Ignore representation ids that are not valid + representations = { + representation_id for representation_id in representations + if is_valid_uuid(representation_id) + } + repre_entities = ayon_api.get_representations( project_name=context.data["projectName"], representation_ids=representations, diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 1267c009e7..0a8fc93cf7 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -1,9 +1,20 @@ +import uuid + import ayon_api import pyblish.api from ayon_core.pipeline import registered_host +def is_valid_uuid(value) -> bool: + """Return whether value is a valid UUID""" + try: + uuid.UUID(value) + except ValueError: + return False + return True + + class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder + 0.0001 @@ -40,6 +51,10 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): container["representation"] for container in containers } + repre_ids = { + repre_id for repre_id in repre_ids + if is_valid_uuid(repre_id) + } project_name = context.data["projectName"] repre_entities = ayon_api.get_representations( @@ -65,7 +80,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): continue # NOTE: - # may have more then one representation that are same version + # may have more than one representation that are same version version = { "container_name": con["name"], "representation_id": repre_entity["id"],