[FIXED] Blender 3.0 Breaks node-groups in some addons

Hello friends;

I don’t know exactly what changed, but in Blender 3.0, I cannot use the builtin Group Input or Group Output nodes anymore in my (not-yet-public) addon. I based my implementation of node-groups on Sorcar, and it has the same problem.
It seems a poll() function was added that makes node input/output incapable of connecting to non-builtin socket types.
I’m sure this was well-meaning, but, eh… it breaks my addon!

I don’t want to submit a Bug Report to Blender just yet, since I would like to hear back from devs about the reason for this change and the right way for addon developers to address it.

I hope the answer is not “Re-implement it yourself” because this was not necessary in past Blender versions. I would argue that this is a regression bug.

I am having trouble finding a definition of the NodeGroupInput node… it seems it is defined in C somewhere.
https://developer.blender.org/diffusion/B/browse/master/?grep=NodeGroupInput
Search doesn’t yield anything I can really understand.

It seems the bpy.types.NodeSocketVirtual class is responsible for the behavior.
Here is the result of dir(NodeSocketVirtual):

['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', 'as_pointer', 'bl_rna', 'bl_rna_get_subclass', 'bl_rna_get_subclass_py', 'driver_add', 'driver_remove', 'get', 'id_data', 'id_properties_clear', 'id_properties_ensure', 'id_properties_ui', 'is_property_hidden', 'is_property_overridable_library', 'is_property_readonly', 'is_property_set', 'items', 'keyframe_delete', 'keyframe_insert', 'keys', 'links', 'path_from_id', 'path_resolve', 'pop', 'property_overridable_library_set', 'property_unset', 'type_recast', 'values']

It does not appear to have the poll function I was expecting. Nor does the node itself NodeGroupInput, have the ‘socket_value_update’ function I was expecting (which would usually be used to mark or disconnect illegal links).

Thus I believe this is a regression bug in Blender. I would like a second pair of eyes to look at it, though. I can prepare a minimal example later, perhaps… although node API is very hands-on and requires a lot of Python to produce a minimal example.
EDIT:
The relevant files in Sorcar are https://github.com/aachman98/Sorcar/blob/master/nodes/utilities/ScNodeGroup.py
and
https://github.com/aachman98/Sorcar/blob/master/operators/ScGroupNodes.py
The bug occurs on line 85 of this file, when attempting to connect the GroupInput node to a custom node, but Python does not throw an error until line 94, when previously functional code would attach a link to the newly-created input in the Group Node.

It looks like the Sorcar code is not calling inputs.new() or outputs.new() on the new node group. I think you need to do this before you can successfully link to the group-input and group-output nodes.

In previous versions of Blender, you could get an intermittent crash from not doing this properly.

In my version of a1studmuffin’s spaceship-generator addon, I am careful to do this properly. And that seems to work OK with Blender 3.0.

Hello, thank you for making me aware of this.
Even still, it seems a bit ham-fisted to fix a bug by disabling a previously (mostly) functional behavior. especially because T75959 is not marked as solved, I think this is an accidental regression.

Anyhow, I will go ahead and try to implement a fix in my addon and send it on over to Sorcar following the method you mentioned! Thanks for the reply.

I made a bug report:
https://developer.blender.org/T94827

I remember that i had to use the ops version of this operator because this part of the API is dead

bpy.ops and selection management are things I try very hard to avoid. I’m hoping that I’ll learn the “Blender-approved” way of doing things soon.
For my addon I had to do a lot of clever thinking to implement node-groups, I wish I had had a guide. Maybe I should make one.

1 Like

Fixed by “⚙ D13817 Fix T94827: Group Input/Output cannot connect to custom sockets

Yeah, I look on operators as a last resort. They are supposed to define UI actions, whereas what I want to do in my scripts are programmatic actions, that should not be dependent on UI layout/state/settings in any way.