Shotgrid Addon Sync Issues

SG Addon: 0.3.2

Hi all,
I am testing out the Shotgrid (Or rather Flow Production Tracking lol) Addon. And come across the following error when syncing across a character asset from SG to Ayon:

Error
Logged in as user "service_key"
2024-03-26 03:51:59 DEBUG      Succesfully connected to Shotgrid.
2024-03-26 03:52:00 INFO       Project BJ0003_Ayon_SGCreated_Test <BJ0003_Ayon_SGCreated_Test> already exists in AYON.
2024-03-26 03:52:00 INFO       Project BJ0003_Ayon_SGCreated_Test (BJ0003) <519> already exists in Shotgrid.
2024-03-26 03:52:01 DEBUG      Transforming sg_entity '{'type': 'Asset', 'id': 1778, 'code': 'TestChar', 'sg_status_list': 'wtg', 'tags': [], 'project': {'id': 519, 'name': 'BJ0003_Ayon_SGCreated_Test', 'type': 'Project'}, 'shots': [], 'sg_asset_type': 'Character', 'sg_ayon_id': None, 'sg_ayon_sync_status': None}' to ayon dict.
2024-03-26 03:52:01 WARNING    Shotgrid Missing Ayon ID
2024-03-26 03:52:01 ERROR      Unable to process handler shotgrid_event
2024-03-26 03:52:01 ERROR      'NoneType' object has no attribute 'lower'

	Traceback (most recent call last):
	File "/service/processor/processor.py", line 161, in start_processing
         handler.process_event(
       File "/service/processor/handlers/shotgrid_event.py", line 45, in process_event
         hub.react_to_shotgrid_event(sg_payload["meta"])
       File "/service/ayon_shotgrid_hub/__init__.py", line 335, in react_to_shotgrid_event
         update_ayon_entity_from_sg_event(
       File "/service/ayon_shotgrid_hub/update_from_shotgrid.py", line 213, in update_ayon_entity_from_sg_event
         ["task" if sg_entity_dict.get(CUST_FIELD_CODE_ID).lower() == "task" else "folder"]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     AttributeError: 'NoneType' object has no attribute 'lower'
     
 
 2024-03-26 03:52:01 ERROR      403 Client Error: Forbidden for url: http://XX.XX.XX.XX:5000/api/events/f4406cf0eb2311eeaaa30242ac130004
 
     Traceback (most recent call last):
       File "/service/processor/processor.py", line 161, in start_processing
         handler.process_event(
       File "/service/processor/handlers/shotgrid_event.py", line 45, in process_event
         hub.react_to_shotgrid_event(sg_payload["meta"])
       File "/service/ayon_shotgrid_hub/__init__.py", line 335, in react_to_shotgrid_event
         update_ayon_entity_from_sg_event(
       File "/service/ayon_shotgrid_hub/update_from_shotgrid.py", line 213, in update_ayon_entity_from_sg_event
         ["task" if sg_entity_dict.get(CUST_FIELD_CODE_ID).lower() == "task" else "folder"]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     AttributeError: 'NoneType' object has no attribute 'lower'
     
     During handling of the above exception, another exception occurred:
     
     Traceback (most recent call last):
       File "/usr/local/lib/python3.11/site-packages/ayon_api/server_api.py", line 199, in raise_for_status
         self._response.raise_for_status()
       File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
         raise HTTPError(http_error_msg, response=self)
     requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://XX.XX.XX.XX/api/events/f4406cf0eb2311eeaaa30242ac130004
     
     During handling of the above exception, another exception occurred:
     
     Traceback (most recent call last):
       File "/service/processor/processor.py", line 176, in start_processing
         ayon_api.update_event(
       File "/usr/local/lib/python3.11/site-packages/ayon_api/_api.py", line 518, in update_event
         return con.update_event(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       File "/usr/local/lib/python3.11/site-packages/ayon_api/server_api.py", line 1456, in update_event
         response.raise_for_status()
       File "/usr/local/lib/python3.11/site-packages/ayon_api/server_api.py", line 203, in raise_for_status
         raise HTTPRequestError(message, exc.response)
     ayon_api.exceptions.HTTPRequestError: 403 Client Error: Forbidden for url: http://XX.XX.XX.XX/api/events/f4406cf0eb2311eeaaa30242ac130004

Obviously sg_parent_entity_dict.get(CUST_FIELD_CODE_ID) isn’t returning anything, presumably due to the Client Error? This only occurs when the leecher finds and syncs a character asset as it works fine with other asset types (prop, env, vehicle) so its a bit strange it fails here.

Is there a best practice I am not following? I am creating assets in SG then syncing them across, is there some catch I’m missing? I have tried with both the flat and Type > Asset Hierarchy in SG so I don’t believe that is the issue.

I would also note that deleting assets in SG doesn’t seem to remove them from Ayon despite the logs saying that it worked.

Summary
DEBUG      Succesfully connected to Shotgrid.
INFO       Project BJ0003_Ayon_SGCreated_Test <BJ0003_Ayon_SGCreated_Test> already exists in AYON.
INFO       Project BJ0003_Ayon_SGCreated_Test (BJ0003) <519> already exists in Shotgrid.
DEBUG      Transforming sg_entity '{'type': 'Asset', 'id': 1780, 'code': 'Motorbike', 'sg_status_list': 'wtg', 'tags': [], 'project': {'id': 519, 'name': 'BJ0003_Ayon_SGCreated_Test', 'type': 'Project'}, 'shots': [], 'sg_asset_type': 'Vehicle', 'sg_ayon_id': '0afbb312eb3011ee958300155d700f23', 'sg_ayon_sync_status': None}' to ayon dict.
DEBUG      SG Entity as Ay dict: {'label': 'Motorbike', 'name': 'Motorbike', 'shotgridId': 1780, 'shotgridType': 'Asset', 'sg_ayon_id': '0afbb312eb3011ee958300155d700f23', 'sg_ayon_sync_status': None, 'type': 'Asset'}
INFO       Deleting AYON entity: <FolderEntity - 0afbb312eb3011ee958300155d700f23>
INFO       Event has been processed... setting to finished!

Apologies, while I am at it, how can you add support for other pipeline steps that are not there by default? The Concept art pipeline step doesn’t appear to exist in Ayon. Is this something easily added or is it better to just avoid using non standard pipeline steps?

Cheers,
Stephen

A small update, pipeline steps can be added in Ayon in the Project Anatomy under Tasks. These also appear to be added automatically by the Processor when adding a task from SG that doesn’t yet exist in Ayon:

The issue I had that prompted the question was due to the task template I was using in SG having a task without a pipeline step assigned to it so Ayon had nothing to base it’s task creation on.

Hello,
Does the issue still exist ?

Does this post helps ?