mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
added more validations to load utils
This commit is contained in:
parent
1a1fce289d
commit
cff6add784
1 changed files with 20 additions and 3 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import os
|
||||
import uuid
|
||||
import platform
|
||||
import logging
|
||||
import inspect
|
||||
import collections
|
||||
import numbers
|
||||
from typing import Any
|
||||
|
||||
import ayon_api
|
||||
|
||||
|
|
@ -464,8 +466,13 @@ def update_container(container, version=-1):
|
|||
|
||||
# Compute the different version from 'representation'
|
||||
project_name = get_current_project_name()
|
||||
repre_id = container["representation"]
|
||||
if not _is_valid_representation_id(repre_id):
|
||||
raise ValueError(
|
||||
f"Got container with invalid representation id '{repre_id}'"
|
||||
)
|
||||
current_representation = ayon_api.get_representation_by_id(
|
||||
project_name, container["representation"]
|
||||
project_name, repre_id
|
||||
)
|
||||
|
||||
assert current_representation is not None, "This is a bug"
|
||||
|
|
@ -817,6 +824,16 @@ def get_outdated_containers(host=None, project_name=None):
|
|||
return filter_containers(containers, project_name).outdated
|
||||
|
||||
|
||||
def _is_valid_representation_id(repre_id: Any) -> bool:
|
||||
if not repre_id:
|
||||
return False
|
||||
try:
|
||||
uuid.UUID(repre_id)
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def filter_containers(containers, project_name):
|
||||
"""Filter containers and split them into 4 categories.
|
||||
|
||||
|
|
@ -852,7 +869,7 @@ def filter_containers(containers, project_name):
|
|||
repre_ids = {
|
||||
container["representation"]
|
||||
for container in containers
|
||||
if container["representation"]
|
||||
if _is_valid_representation_id(container["representation"])
|
||||
}
|
||||
if not repre_ids:
|
||||
if containers:
|
||||
|
|
@ -917,7 +934,7 @@ def filter_containers(containers, project_name):
|
|||
for container in containers:
|
||||
container_name = container["objectName"]
|
||||
repre_id = container["representation"]
|
||||
if not repre_id:
|
||||
if not _is_valid_representation_id(repre_id):
|
||||
invalid_containers.append(container)
|
||||
continue
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue