ID 549604 - A "Missing end_group command(s)" error occurs when creating a Gizmo from a PyScript_Knob

Follow

Problem summary:
A "Missing end_group command(s)" error occurs when creating a Gizmo from a PyScript_Knob
 
Customer reported version:
Nuke 14.0v5
 
Customer reported platform:
Windows 10
 
Steps to reproduce:
1) Launch Nuke and create a Group node in the Node Graph.
2) In the Group's Properties Panel, press the export as gizmo... button, and save it inside the ~/.nuke directory as myGizmo.gizmo, or similar:


3) Create a NoOp node in the Node Graph, the Group can be deleted at this point if desired. 
4) Open the Script Editor window and run the following code:

noop_node = nuke.toNode("NoOp1")knob = nuke.PyScript_Knob("test", "test", "nuke.createNode('myGizmo')")noop_node.addKnob(knob)
4) Click the NoOp node's "test" button and observe the error message: Missing end_group command(s)

 
Expected behavior:
Gizmo creation code called by PyScript_Knobs should behave the same as code called from the Script Editor.
 
Actual behavior:
Creating a Gizmo from a PyScript_Knob produces a "Missing end_group command(s)" error message. In Nuke's Terminal, the error looks like this:

 
This problem also occurs when using nuke.nodes.nodeName(), rather than nuke.createNode()
node = nuke.toNode("NoOp1") knob = nuke.PyScript_Knob("test", "test", "nuke.nodes.myGizmo()") node.addKnob(knob)
 
However, the issue does not seem to occur with basic nodes, like a Blur or Grade:
node = nuke.toNode("NoOp1") knob = nuke.PyScript_Knob("test", "test", "nuke.createNode('Blur')") node.addKnob(knob)
 
Workaround:
To prevent this error message from occurring, use a QTimer to wrap the Gizmo creation code, like the example below:
from PySide2.QtCore import QTimer node = nuke.toNode("NoOp1") knob = nuke.PyScript_Knob("test", "test", "QTimer().singleShot(1, lambda: nuke.createNode('myGizmo'))") node.addKnob(knob)
 
Reproduced by Support in:
Nuke 14.0v5 - Windows 10, CentOS 7
Nuke 14.0v1 - Windows 10
Nuke 13.0v1 - Windows 10
Nuke 12.0v1 - Windows 10
Nuke 11.0v1 - Windows 10
Nuke 10.0v1 - Windows 10, CentOS 7
 
Earliest version tested:
Nuke 10.0v1 - This issue appears to be in all tested versions of the product 

    We're sorry to hear that

    Please tell us why