ID 419347 - Preferences can be set to unsupported values via Python

Follow

Problem summary
When setting Katana preferences via Python, it is possible to set a preference to a value of a type that the preference shouldn't accept (for example a string value for a preference that should only accept integers). This can lead to issues like errors when initialising the UI, preventing users from launching the software.

Customer reported version
Katana 3.2v1

Customer reported platform
Windows 10

Steps to reproduce

Run the following code in a Python tab in Katana:

from UI4.KatanaPrefs import Prefs, PrefNames

Prefs[PrefNames.RENDERING_THREADS_2D] = "I'm a string"

Expected behaviour
As this preference (application\rendering\interactiveRenderThreads2D) should accept integer values only, the value of the preference is not modified and a warning or error message is shown to the user.

Actual behaviour

  • The value of the preference as reflected in the ~/.katana/Prefs2.ini file is set to "I'm a string".

  • An error appears in the console and the Messages tab (but the preference value is saved still):
    Error in event handler __renderThreads_pref_callback() for event type "pref_changed": ValueError: invalid literal for int() with base 10: "I'm a string"
  • On closing and reopening Katana, initialising the UI fails when preferences are parsed and Katana doesn't open, with the following error message appearing in the console:
[ERROR python.root]: A ValueError occurred in "KatanaPrefsObject.py": invalid literal for int() with base 10: "I'm a string"

Traceback (most recent call last):

File "python/Main\Main.py", line 429, in <module>

File "python/Main\Main.py", line 413, in __main

File "MainUI.py", line 15, in Main

File "MainUI.py", line 36, in Main

File "MainUI.py", line 59, in InitializeInterface

File "App/__init__.py", line 22, in <module>

File "App/AutoSave.py", line 21, in <module>

File "KatanaPrefs/__init__.py", line 177, in <module>

File "KatanaPrefs/KatanaPrefsObject.py", line 120, in declareIntPref

ValueError: invalid literal for int() with base 10: "I'm a string"

Workaround

  • Remove or rename the ~/.katana/Prefs2.ini file or the entire ~/.katana folder to launch Katana with default preferences.
  • Open the ~/.katana/Prefs2.ini file in a text editor and manually change the affected value to a valid one.

Reproduced by support
Katana 3.2v3 - Windows 10/CentOS7
Katana 3.1v1 - Windows 10/CentOS7

Partially reproduced
The following versions allow the preference to be set to an unsupported value, but seem to fall back to the default on the next launch instead of using the invalid preference value and replace the previous value with the default in Prefs2.ini on close:

Katana 3.0v1 - Windows 10/CentOS7
Katana 2.6v3 - Windows 10/CentOS7
Katana 2.5v1 - Windows 10/CentOS7
Katana 1.6v3 - CentOS 7

    We're sorry to hear that

    Please tell us why