Skip to content

Conversation

@dchiquito
Copy link
Contributor

@dchiquito dchiquito commented Oct 31, 2025

Related Issue

Fixes #1182

New Behavior

  • In the netbox_contact module, rename contact_group to contact_groups.
  • Add an integration test for adding contacts to contact groups.
  • Add integration tests for contact groups in general.

Contrast to Current Behavior

Currently you can only specify a single group per contact, and you must use an integer ID which is difficult to do in ansible (see #1182).
After this change you can specify a list of groups by name or slug, which is more useful and more ergonomic.

Discussion: Benefits and Drawbacks

This is a breaking change, as anyone who has succeeded in using the old broken contact_group field despite the bugginess will need to update.
The new API is much nicer IMHO.
I suspect contact_groups was the original intention that simply wasn't finished correctly, as there were several references to it in netbox_utils.py already. I only had to add three ss to netbox_utils.py to get it working nicely.

Changes to the Documentation

No changes besides the updated auto module docs.

Proposed Release Note Entry

Change netbox_contacts.contact_group to contact_groups (see #1182)

Double Check

  • I have read the comments and followed the CONTRIBUTING.md.
  • I have explained my PR according to the information in the comments or in a linked issue.
  • My PR targets the devel branch.

There were several places in `netbox_utils.py` that referred to
`contact_groups` for no apparent reason, and some that referred to
`contact_group` despite the feature being buggy (see
netbox-community#1182).

As a contact can belong to multiple groups, I think `contact_groups`
makes more sense, and fixes the bugggy behavior.
@dchiquito dchiquito marked this pull request as ready for review October 31, 2025 18:54
@dchiquito dchiquito marked this pull request as draft October 31, 2025 19:30
@dchiquito
Copy link
Contributor Author

I just discovered that https://github.com/netbox-community/netbox/releases/tag/v4.3.0 changed group to groups, so this new code will not work on older versions of Netbox.
I'm working on adding back a group field that will work with the old API while keeping groups that will work on the new API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cannot add contact_group to contact

1 participant