Context_from_entity returning empty context for Assets


I’ve been trying the multi-publish2 tool and found that when I enter a new Asset in the Link field it fails.
Traceback (most recent call last):
File “/rakete/home/ldap/nrehberg/workspace/gits/mau/sgtk/install/app_store/tk-framework-qtwidgets/v2.8.6/python/context_selector/”, line 633, in _on_entity_activated
File “/rakete/home/ldap/nrehberg/workspace/gits/mau/sgtk/install/app_store/tk-framework-qtwidgets/v2.8.6/python/context_selector/”, line 623, in _on_context_activated
File “/rakete/home/ldap/nrehberg/workspace/gits/mau/sgtk/install/app_store/tk-framework-qtwidgets/v2.8.6/python/context_selector/”, line 841, in _show_context
link_display = _get_link_display(context)
File “/rakete/home/ldap/nrehberg/workspace/gits/mau/sgtk/install/app_store/tk-framework-qtwidgets/v2.8.6/python/context_selector/”, line 903, in _get_link_display
entity_name = entity[“name”]
KeyError: ‘name’

I followed the code and found that the problem lies in context_from_entity, which returns an None Asset:
DEBUG [16:27:45 425.107955933]: Context changed to: Asset None

After some more digging in the call in line 1242
entity_context = _context_data_from_cache(tk, entity_type, entity_id)
gives back this

{'project': {'type': 'Project', 'id': 89, 'name': 'Maurice'}, 'additional_entities': [], 'step': None, 'task': None, 'tk': <Sgtk Core v0.18.172@0x7f486b6d0150 Config /rakete/home/ldap/nrehberg/workspace/gits/mau/sgtk>, 'user': None, 'source_entity': None, 'entity': {'type': u'Asset', 'id': 1729}}

Since the project dict is filled in, the following check on line 1245 does not trigger a real shotgun lookup and thus I get a broken context back. Is this a bug?
This seems to only happen with Assets, when I use the Task field and thus context_from_entity queries a task it works fine.
For now I’ll add an extra check for the entity name in line 1245 , which seems to help.



Hi Nico

I’m sorry you’ve run into this, it is, unfortunately, a known bug, and I’ve linked this thread up with our internal bug ticket so we can report back when it’s complete. I don’t know when this ticket will be got to yet though.

To work around it, you need to ensure that the folders have been created for that asset, and that the path cache is in sync.


1 Like

Hi Philip,
thanks for the info. Creating workfolders is not really an option, since I would need to create or check them for all assets in the project before showing the UI. That could take quite some time.

Let’s see how far we get with that extra check I mentioned above.