ID 611328 - The filenameFilter callback and the Path Substitutions Preferences do not work as expected

Follow

Problem summary
The filenameFilter callback and the Path Substitutions Preferences do not work as expected.
On Windows and macOS, this issue has been reproduced with Read node paths and the custom OCIO config path. On Linux, this issue does not seem to occur with Read nodes.
 
Customer reported version
Nuke 16.0v7
 
Customer reported platform
Rocky 9
 
Steps to reproduce
 
1) Open Nuke.
 
2) Create a Read node.
 
3) Set its file knob to a path/file that doesn't exist. For example: C:/fake/AwesomePicture.jpeg
 
4) Save and close the script.
 
5) Run the following code in the Script Editor. This should resolve the Read node's file path to C:/temp/AwesomePicture.jpeg so this file should exist on your system:
 
def myFilenameFilter(filename):    new_filename = filename.replace("C:/fake/", "C:/temp/")    print(filename, new_filename)    return new_filenamenuke.addFilenameFilter(myFilenameFilter)
 
6) Reopen the script. You should see something like the following printed in the Script Editor's output:
 
C:/fake/AwesomePicture.jpeg C:/temp/AwesomePicture.jpeg
However, the Read node will still be in an error state.
 
 
Steps to reproduce - Path Substitutions
 
1) Open Nuke.
 
2) Create a Read node.
 
3) Set its file knob to a path/file that doesn't exist. For example: C:/fake/AwesomePicture.jpeg
 
4) Save and close the script.
 
5) In Edit > Preferences > General > Path Substitutions, set the path for your current OS to a real path and the path on another OS to the path on your Read node.
In this case, this should resolve the Read node's file path to C:/temp/AwesomePicture.jpeg on Windows. This file will need to exist on your system:
 

 
6) Close and reopen Nuke, to ensure the Preferences take affect.
 
7) Reopen the script.
 
 
Steps to reproduce - OCIO config path
 
1) Open Nuke.
 
2) In Project Settings (Edit > Project Settings) and set the following:
 
  • color management to OCIO
  • OCIO config to custom
  • custom OCIO config to the path of one of your config files (ie. /fake/<username>/Documents/ocio/config.ocio)
 
3) Save and close the script.
 
4) Run the following code in the Script Editor. This should resolve the custom OCIO config path to /home/<username>/Documents/ocio/config.ocio so this file should exist on your system:
 
def myFilenameFilter(filename):    new_filename = filename.replace("/fake/", "/home/")    print(filename, new_filename)    return new_filenamenuke.addFilenameFilter(myFilenameFilter)
 
5) Reopen the script. 
 
 
Expected behavior
The filenameFilter callback and Path Substitution Preferences should update the Read node and custom OCIO config file paths.
 
Actual behavior
The filenameFilter callback and Path Substitution Preferences do not work. The Read node is in an error state (Windows only) and there are OCIO errors, when reopening the script.
 
Workaround
Instead of relying on the path substitutions preferences, it should be possible to avoid these issues by explicitly updating the value of the Root's customOCIOConfigPath knob and or Read node's file knob, like with the following onScriptLoad and onCreate callbacks:
import nukedef ocioPathUpdate():    filename = nuke.root()["customOCIOConfigPath"].value()    if nuke.env['MACOS']:         filename = filename.replace( 'C:/Users', '/home/user' )     else:         filename = filename.replace( '/home/user', 'C:/Users' )     nuke.root()["customOCIOConfigPath"].setValue(filename) nuke.addOnScriptLoad(ocioPathUpdate) 
import nukedef readPathUpdate():    filename = nuke.thisNode()["file"].value()     if nuke.env['MACOS']:        filename = filename.replace( 'C:/Users', '/home/user' )    else:        filename = filename.replace( '/home/user', 'C:/Users' )    nuke.thisNode()["file"].setValue(filename)nuke.addOnCreate(readPathUpdate, nodeClass="Read")

 
Reproduced by Support in:
Nuke 16.0v7 - Windows 11 - macOS 15 (Sequoia) - Linux Rocky 9
Nuke 16.0v6 - Windows 11 
Nuke 16.0v5 - Windows 11 - macOS 15 (Sequoia) -- Regression
 
Unable to reproduce bug in:
Nuke 16.0v4 - Windows 11 - macOS 15 (Sequoia) - Linux Rocky 9
 
Earliest version tested
Nuke 16.0v4 - This issue doesn't appear in this version and has regressed

    We're sorry to hear that

    Please tell us why