cpenv / tk-cpenv

Shotgun Toolkit Application that adds support for cpenv modules.
Other
20 stars 5 forks source link

User Restriction dialog broken #20

Closed fabiangeisler closed 1 year ago

fabiangeisler commented 1 year ago

When I try to click on user restriction in the GUI I get this broken dialog displayed: image and this error log in the SGTK console:

2022-08-23 13:06:22,212 [   ERROR] [PROXY] Traceback (most recent call last):
  File "/home/fabian.geisler/.shotgun/bundle_cache/github/cpenv/tk-cpenv/v0.5.10/python/cpenv_ui/env_permissions.py", line 66, in on_initialized
    except Exception:
  File "/home/fabian.geisler/.shotgun/bundle_cache/github/cpenv/tk-cpenv/v0.5.10/app.py", line 151, in debug
    self.logger.debug('tk-cpenv: %s' % (message % args))
TypeError: not enough arguments for format string

which is actually a bug in the except block of the initialization of the user widget. By changing env_permissions.py line 66 from:

app.debug(traceback.format_exc())

to

app.logger.exception('Error on initialize.')

I get this more helpful error:

2022-08-23 13:13:42,014 [   ERROR] [PROXY] Error on initialize.
Traceback (most recent call last):
  File "/home/fabian.geisler/.shotgun/bundle_cache/github/cpenv/tk-cpenv/v0.5.10/python/cpenv_ui/env_permissions.py", line 62, in on_initialized
    parent=self,
  File "/home/fabian.geisler/.shotgun/bundle_cache/app_store/tk-framework-qtwidgets/v2.10.3/python/shotgun_fields/shotgun_field_manager.py", line 326, in create_widget
    sg_entity_type, field_name, entity, parent, **kwargs
  File "/home/fabian.geisler/.shotgun/bundle_cache/app_store/tk-framework-qtwidgets/v2.10.3/python/shotgun_fields/shotgun_field_manager.py", line 499, in _create_editor_widget
    if not shotgun_globals.field_is_editable(sg_entity_type, field_name):
  File "/home/fabian.geisler/.shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.8.5/python/shotgun_globals/cached_schema.py", line 898, in field_is_editable
    "Could not find the schema for %s.%s" % (sg_entity_type, source_field_name)
ValueError: Could not find the schema for CustomEntity03.sg_permissions_users

This seems to indicate that some local ShotGrid schema cache is not updated correctly and I don't know why that is. Restarting SG Desktop does not help. I will dig some more to try to find the cause of this.

Any hint or fix is much appreciated!

PS: No promises, but if time allows I will submit a PR for the broken debug statement in the except block.

danbradham commented 1 year ago

Hmmm, I haven't run into this issue before. It kind of sounds like the field name could be incorrect, or it could have the incorrect type? It should be a multi-entity person field iirc. I'm not sure if there's a way to force a recache of the schema, in fact, I wasn't even aware that they did cached field schemas!

I always appreciate pull requests but I'll be back on my machine in another week or so. Hopefully this isn't blocking you completely.

fabiangeisler commented 1 year ago

Hi @danbradham! Thanks for the reply. This is not blocking for me, since I can still fill the field manually on the SG environment entity. I've checked like 10 times if the field has the right name and type and since it is working with the rest of the code it is correct. The comes form this weird schema cache that the widget uses. I also did not know about it up until now. Will see if I can somehow force it to update and report here again.

fabiangeisler commented 1 year ago

Well in the end I needed to delete this file: /home/fabian.geisler/.shotgun/automatik-vfx/p87c126.basic.desktop/fw-shotgunutils/sg_schema.pickle Which fixed the issue for me. This file seems to be created for each project and each pipeline configuration individually, so if you have a very old project (like my pipeline test project) it is likely outdated. I could not find a point in code where this is updated. 😒 Maybe there exists a better way of handling this, but I am not willing to spend more time on this. I will create a PR for the broken log messages and than we can close this issue.