# Getting a crash using multi-workfiles missing task template

**URL:** <https://community.shotgridsoftware.com/t/getting-a-crash-using-multi-workfiles-missing-task-template/11497>\
**Category:** Pipeline Integrations\
**Tags:** bug\
**Created:** [February 5, 2021, 11:41pm UTC](https://community.shotgridsoftware.com/t/getting-a-crash-using-multi-workfiles-missing-task-template/11497 "2021-02-05T23:41:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahuge](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ahuge/32/395_2.png) [@Ahuge](https://community.shotgridsoftware.com/u/Ahuge)\
**Post date:** [February 5, 2021, 11:41pm UTC](https://community.shotgridsoftware.com/t/getting-a-crash-using-multi-workfiles-missing-task-template/11497/1 "2021-02-05T23:41:52Z")

</div>

Hi I think I am hitting a bug, and I am unclear why it’s popping up.

It looks like when I have only 1 shot and that shot is missing a task template this triggers maybe?  
I’m not 100% sure on the cause, hopefully someone here can give me a hand if it’s obvious on your side.

Basically the `shotgun_model` that is returning data for the File Open form is hitting a KeyError and crashing nuke.

The location of the KeyError is here: [tk-framework-shotgunutils/master/python/shotgun\_model/shotgun\_model.py](https://github.com/shotgunsoftware/tk-framework-shotgunutils/blob/91f98f69c728ef024fab0a046ce557c182c521dd/python/shotgun_model/shotgun_model.py#L660)

Here is the traceback:

```auto
Traceback (most recent call last):
  File "/opt/shotgun_cache/dpoe/archplatform/p124c1.basic.desktop/cfg/install/core/python/tank/platform/engine.py", line 1685, in _create_widget
    widget = derived_widget_class(*args, **kwargs)
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-multi-workfiles2/v0.12.3/python/tk_multi_workfiles/file_open_form.py", line 47, in __init__
    FileFormBase. __init__ (self, parent)
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-multi-workfiles2/v0.12.3/python/tk_multi_workfiles/file_form_base.py", line 70, in __init__
    self._entity_models = self._build_entity_models()
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-multi-workfiles2/v0.12.3/python/tk_multi_workfiles/file_form_base.py", line 241, in _build_entity_models
    bg_task_manager=self._bg_task_manager,
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-multi-workfiles2/v0.12.3/python/tk_multi_workfiles/entity_models/extended_model.py", line 71, in __init__
    entity_type, filters, hierarchy, fields, *args, **kwargs
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-framework-shotgunutils/v5.7.6/python/shotgun_model/shotgun_entity_model.py", line 84, in __init__
    self._load_data(entity_type, filters, hierarchy, fields)
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-framework-shotgunutils/v5.7.6/python/shotgun_model/shotgun_model.py", line 386, in _load_data
    None, root, self._create_item
  File "/opt/shotgun_cache/dpoe/archplatform/p124c1.basic.desktop/cfg/install/core/python/tank/log.py", line 514, in wrapper
    response = func(*args, **kwargs)
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-framework-shotgunutils/v5.7.6/python/shotgun_model/data_handler.py", line 272, in generate_child_nodes
    factory_fn(parent_object, data_item)
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-framework-shotgunutils/v5.7.6/python/shotgun_model/shotgun_model.py", line 622, in _create_item
    self._update_item(item, data_item)
  File "/opt/shotgun_cache/dpoe/bundle_cache/app_store/tk-framework-shotgunutils/v5.7.6/python/shotgun_model/shotgun_model.py", line 660, in _update_item
    {"name": data_item.field, "value": data_item.shotgun_data[data_item.field]},
KeyError: 'entity.Shot.sg_sequence.Sequence.episode'

```

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [February 8, 2021, 8:02am UTC](https://community.shotgridsoftware.com/t/getting-a-crash-using-multi-workfiles-missing-task-template/11497/2 "2021-02-08T08:02:40Z")

</div>

The `entity.Shot.sg_sequence.Sequence.episode` field was not present in the data that was queried from Shotgun. Most likely the query contains a set list of fields, or ones obtained from the context. Actually you can see [here](https://github.com/shotgunsoftware/tk-multi-workfiles2/blob/f1aabeb5755a063b5b5b62c11fa104fcbacc83ec/python/tk_multi_workfiles/file_form_base.py#L244) how the field list is created. Perhaps there’s more to it than I’m seeing right now.

Can’t remember if two-level-deep references like this work at all.

---

<div class="post-metadata">

**Author:** ![Ahuge](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ahuge/32/395_2.png) [@Ahuge](https://community.shotgridsoftware.com/u/Ahuge)\
**Post date:** [February 8, 2021, 8:06am UTC](https://community.shotgridsoftware.com/t/getting-a-crash-using-multi-workfiles-missing-task-template/11497/3 "2021-02-08T08:06:57Z")

</div>

Hey Mois,

I think I’m daft, I just realized that’s in my workfiles config… and the project I had linked it to didn’t have episodes.

This is 100% my fault 😕

Thanks for your help, it made me run a find on my config which lead me to my own fault 😛  
-Alex
