Handles missing data in workfile entities
Ensures that the code gracefully handles cases where the 'data' key is missing or None within the workfile entity. This prevents potential errors and improves the robustness of the workfile processing logic.
Changelog Description
This handles an issue where publish is not able to raise workfile version.
Seems to be workfiles issue, DCC unrelated (Nuke/Maya/Substance) I was not able to reproduce this error on my machine, but it happened on several artist machines.
Additional info
Relevant traceback:
Traceback (most recent call last):
File "C:\Users\PSmekal\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\dependencies\pyblish\plugin.py", line 528, in __explicit_process
runner(*args)
File "C:\Users\PSmekal\AppData\Local\Ynput\AYON\addons\nuke_0.3.10\ayon_nuke\plugins\publish\increment_script_version.py", line 40, in process
save_next_version(
File "C:\Users\PSmekal\AppData\Local\Ynput\AYON\addons\core_1.5.2\ayon_core\pipeline\workfile\utils.py", line 492, in save_next_version
workfiles = host.list_workfiles(
File "C:\Users\PSmekal\AppData\Local\Ynput\AYON\addons\core_1.5.2\ayon_core\host\interfaces\workfiles.py", line 1127, in list_workfiles
version = _data.get("version")
AttributeError: 'NoneType' object has no attribute 'get'
Testing notes:
- start with this step
- follow this step
Ensures that the code gracefully handles cases where the 'data' key is missing or None within the workfile entity.
How that can happen? I'm afraid this won't be merged. Those data are must have with workfiles api. The keys might not be there (backwards compatibility) but skipping fetching them is a bug.
Ensures that the code gracefully handles cases where the 'data' key is missing or None within the workfile entity.
How that can happen? I'm afraid this won't be merged. Those data are must have with workfiles api. The keys might not be there (backwards compatibility) but skipping fetching them is a bug.
I do not know how/why this happen, but it does happen on 3 machines with older (~ 1year old) projects. I was not able to find the reason, or why this is not an issue for most workstations, but those few lines helped 3 artists to work, and not crash their pipeline.
I do understand this might be too sketchy, please show me better way to make workfiles more resilient. Thank you
It means that you have workfile entity that was not created using api but using SQL because api does validate the value and handle null value.
I do recommend to fix the database. You can use something like this:
import ayon_api
affected_projects = [...]
for project in affected_projects:
for workfile in api.get_workfiles(project_name, fields={"id", "data"}):
if workfile["data"] is None:
ayon_api.update_workfile_entity(project_name, workfile["id"], data={})