Repository navigation
Conversation
NetBox stores interface names cut to 64 characters. A Lenovo XCC port is named after the manager model and its Redfish id, which is longer than that, so the name match in map_object_interfaces_to_current_interfaces() never found the stored interface. Without a MAC match the port was created again on every run and NetBox rejected it with "Interface with this Device and Name already exists." Cut the discovered name to the data model length before comparing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
semx
reviewed
Oct 12, 2026
semx
left a comment
Collaborator
There was a problem hiding this comment.
Reproduced the duplicate: run 1 stores the name cut to 64 chars, run 2 compares the full name, finds nothing and creates the port again. Fixing it in the shared matcher is the right place.
- The cutting is done by netbox-sync itself when it creates the object (
object_classes.py,data_model["name"]), not by NetBox, please reword the comment. - If two discovered names share the first 64 chars, the first matches and the second is still created again on every run. A warning when a name gets cut, and when two names collide after the cut, would make that visible.
NBVMInterfacehas the same 64 limit, but disabling the cut for VMs still passes the whole suite; a VM test would cover it.
Small one: the example name is 77 chars, not 79.
Review follow-up: - take the name length from the interface class (NBInterface or NBVMInterface) instead of an existing interface, so it is also known on the first run. - log a warning if two discovered names share the same first 64 characters, only one of them can exist in NetBox. The cut itself is logged at debug level. - fix the comment: netbox-sync cuts the name when it creates the object. - add tests for a VM interface and for colliding names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Thanks, all addressed:
|
semx
approved these changes
Oct 12, 2026
semx
left a comment
Collaborator
There was a problem hiding this comment.
Looks good. I disabled the cut for VMs and dropped the collision warning, and your tests caught both. Fine with debug for the cut itself, a warning for every XCC port on every run would get old fast.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
netbox-sync cuts interface names to 64 characters when it creates them. The check_redfish source names a Lenovo XCC port after the manager model and its Redfish id, for example:
That name is 77 characters long.
map_object_interfaces_to_current_interfaces()compared the full discovered name with the cut name stored in NetBox, so the names never matched. If the MAC address didn't match either, the port was created again on every run, and NetBox rejected it:The XCC IP address and MAC address objects then couldn't be assigned either.
Changes:
module/sources/common/source_base.py: before the name match, cut the discovered name to the name length of the interface class (NBInterfaceorNBVMInterface). The cut is logged at debug level. If two discovered names share the same first 64 characters, a warning is logged, since only one of them can exist in NetBox under that name.tests/test_interface_matching_truncated_name.py: tests that a long device interface name and a long VM interface name match the stored interface, that a long name stays unmatched when no such interface exists, and that colliding names are reported.Tested against NetBox 4.7.2 with the check_redfish inventory files of Lenovo hosts: the XCC ports match their existing interfaces, and a dry-run logs no errors.
pytest: 372 passed, 8 skipped (vcsim installed).🤖 Generated with Claude Code