Tk-multi-workfiles2 not detecting other user's files


I think I found a bug in the WorkArea._resolve_user_sandboxes code.

What is Happening (Bug #1)
The code is fast exiting before it determines my “Sandboxes”.
This is happening because _resolve_user_sandboxes states that it requires all non-optional keys with the exception of user keys. see here

This means that because my template is missing keys like “version” or “extension” it decides to not even try looking for paths.

In an example template like this:

There are required keys {version} and {extension} that cause it to exit before calling sgtk.paths_from_template for my template.

Now maybe there is some arcane knowledge as to why we don’t want that. But from what I can tell, paths_from_template supports globbing the missing keys even if they are required.

That brings me to another bug that I think is in the code.

Bug #2
Assuming the code actually gets to our paths_from_template call, the skip_keys arg is being passed incorrectly. paths_from_template states that skip_keys requires a list not a set. It is directly calling append on that if there are missing required keys. Now because of bug#1 we don’t have any, but that’s not a good enough reason.

This means that even if I patch the code so that it will continue until the paths_from_template call, it errors because you can’t append to a set.

Now, lets assume we cast our user_keys to a list so that it is passed correctly.
The globs it’s building me still are wrong.

I get back globs like this

Which works, except what if all of my paths use the optional keys {name} or {output}. Bummer eh?

Bug #3
paths_from_template supports an argument called skip_missing_optional_keys which we can pass as True that will build globs supporting our optional keys too
see here.

I can submit PRs for this, but I wanted to get some thoughts from the dev team to see if I am making an incorrect assumption somewhere.


1 Like