Skip to content

Commit

Permalink
more safeguard for invalid containers
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Dec 5, 2024
1 parent 373df56 commit b6d3ddc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
14 changes: 7 additions & 7 deletions client/ayon_core/tools/loader/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,14 @@ def get_loaded_product_ids(self):

repre_ids = set()
for container in containers:
repre_id = container.get("representation")
# Ignore invalid representation ids.
# - invalid representation ids may be available if e.g. is
# opened scene from OpenPype whe 'ObjectId' was used instead
# of 'uuid'.
# NOTE: Server call would crash if there is any invalid id.
# That would cause crash we won't get any information.
try:
repre_id = container.get("representation")
# Ignore invalid representation ids.
# - invalid representation ids may be available if e.g. is
# opened scene from OpenPype whe 'ObjectId' was used instead
# of 'uuid'.
# NOTE: Server call would crash if there is any invalid id.
# That would cause crash we won't get any information.
uuid.UUID(repre_id)
repre_ids.add(repre_id)
except (ValueError, TypeError, AttributeError):
Expand Down
17 changes: 11 additions & 6 deletions client/ayon_core/tools/sceneinventory/models/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,24 @@ def _update_cache(self):
return

host = self._controller.get_host()
if isinstance(host, ILoadHost):
containers = list(host.get_containers())
elif hasattr(host, "ls"):
containers = list(host.ls())
else:
containers = []
containers = []
try:
if isinstance(host, ILoadHost):
containers = list(host.get_containers())
elif hasattr(host, "ls"):
containers = list(host.ls())
except Exception:
self._log.error("Failed to get containers", exc_info=True)

container_items = []
containers_by_id = {}
container_items_by_id = {}
invalid_ids_mapping = {}
current_project_name = self._controller.get_current_project_name()
for container in containers:
if not container:
continue

try:
item = ContainerItem.from_container_data(
current_project_name, container)
Expand Down

0 comments on commit b6d3ddc

Please sign in to comment.