You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a member_of_groups relationship is configured on an Object Template, two unexpected things happen:
The template node itself becomes a member of the referenced group as soon as the template is saved.
Objects subsequently created from that template do not inherit the group membership — the group relationship is silently dropped.
Effectively, member_of_groups set on a template applies to the template, never to its instances.
Confirmed in source:
add_groups() in backend/infrahub/core/schema/schema_branch.py injects a member_of_groups relationship into nearly every node kind. Templates are not excluded, so setting member_of_groups on a template literally adds the template node to that real group.
Template instantiation in backend/infrahub/templates/node_applier.py only propagates relationships whose kind is ATTRIBUTE, GENERIC, or PROFILE:
member_of_groups is registered with kind=RelationshipKind.GROUP, so it is skipped at instantiation time.
Expected Behavior
Configuring member_of_groups on an Object Template should express intent for the resulting instances, not for the template itself. Specifically:
Setting member_of_groups on a template should not add the template node to the group.
Each object created from the template should be added as a member of the configured group(s) automatically at creation time.
This is structurally the same problem as #6551 (selecting a resource pool on a template allocated a resource to the template instead of to instances). Resolving it consistently with that precedent — e.g. a template-side field that drives per-instance group membership — would be ideal.
Steps to Reproduce
Spin up an Infrahub instance.
Load a schema with a node that has generate_template: true, e.g.:
Practical impact: event-driven workflows that rely on a CoreGroupTriggerRule firing when a template-instantiated object is added to a group cannot use member_of_groups on the template to drive that membership today; a separate CoreNodeTriggerRule + CoreGroupAction is required as a workaround.
Component
API Server / GraphQL
Infrahub version
1.8.6 and 1.9.0
Current Behavior
When a
member_of_groupsrelationship is configured on an Object Template, two unexpected things happen:Effectively,
member_of_groupsset on a template applies to the template, never to its instances.Confirmed in source:
add_groups()inbackend/infrahub/core/schema/schema_branch.pyinjects amember_of_groupsrelationship into nearly every node kind. Templates are not excluded, so settingmember_of_groupson a template literally adds the template node to that real group.Template instantiation in
backend/infrahub/templates/node_applier.pyonly propagates relationships whose kind isATTRIBUTE,GENERIC, orPROFILE:member_of_groupsis registered withkind=RelationshipKind.GROUP, so it is skipped at instantiation time.Expected Behavior
Configuring
member_of_groupson an Object Template should express intent for the resulting instances, not for the template itself. Specifically:member_of_groupson a template should not add the template node to the group.This is structurally the same problem as #6551 (selecting a resource pool on a template allocated a resource to the template instead of to instances). Resolving it consistently with that precedent — e.g. a template-side field that drives per-instance group membership — would be ideal.
Steps to Reproduce
Spin up an Infrahub instance.
Load a schema with a node that has
generate_template: true, e.g.:Create a
CoreStandardGroup(e.g.staged_devices).Create an object template for
InfraDeviceand addstaged_devicesto itsmember_of_groups.Inspect the group: the template node is listed as a member. (Behavior 1)
Create a new
InfraDevicefrom that template.Inspect the new device's
member_of_groupsand thestaged_devicesgroup: the new device is not a member. (Behavior 2)Additional Information
<rel>_from_resource_poolfield).develop:backend/infrahub/core/schema/schema_branch.py—add_groups()(~line 2195)backend/infrahub/templates/node_applier.py—_apply_relationships()(~line 60), specifically the relationship-kind filter (~line 80)CoreGroupTriggerRulefiring when a template-instantiated object is added to a group cannot usemember_of_groupson the template to drive that membership today; a separateCoreNodeTriggerRule+CoreGroupActionis required as a workaround.