netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Bulk device import no longer works with parent/child devices when "tags" present in import data

Open pmsharp2 opened this issue 4 months ago • 4 comments

Deployment Type

Self-hosted: bare-metal self-hosted: docker

NetBox Version

4.3.4 & 4.3.6

Python Version

3.12

Steps to Reproduce

create a role: test_device create a site: SFO create a location : DC1 (site = SFO) create a manufacturer: nebox create a rack: A01 (site = SFO)(Location = DC1) create device role: test_device create tag: tag1 create a device type "test-shelf" with "netbox" as the manufacture with the "parent" flag and a single device bay named "bay1" create a device type "test-device" with "netbox" as the manufacture the "child" flag and "0" as height

Bulk device import

role	manufacturer	device_type	status	site	location	name	rack	position	face	parent	device_bay	tags
test_device	netbox	test-shelf	planned	SFO	DC1	test-shelf	A01	18	front			tag1
test_device	netbox	test-device	planned	SFO	DC1	test-device	A01			test-shelf	bay1	tag1

Expected Behavior

child device is assigned to the bay of the parent with correct tags assigned to each device

Observed Behavior

Devices are imported but the child device is set as a "non-racked devices" rather than being assigned to the correct device bay. ONLY when a tag is present during the import. This fails both when the parent and child are imported at the same time and when the parent already exists.

Tested on 4.3.4 and 4.3.6 with same results

pmsharp2 avatar Aug 17 '25 11:08 pmsharp2

@pmsharp2 can you please expand and cleanup on your reproduction steps - the csv you've given assumes a lot of things are existing (like site, rack, etc..) that aren't specified in the reproduction steps. Can you please add those and make sure the reproduction steps are complete. I don't think all of the columns in the CSV are needed either, the position, face, etc I don' think are needed?

arthanson avatar Aug 18 '25 19:08 arthanson

@pmsharp2 can you please expand and cleanup on your reproduction steps - the csv you've given assumes a lot of things are existing (like site, rack, etc..) that aren't specified in the reproduction steps. Can you please add those and make sure the reproduction steps are complete. I don't think all of the columns in the CSV are needed either, the position, face, etc I don' think are needed?

site, statues, manufacturer, role are all required and part of the device types. For this import the only non-required fields I have included are rack, position, parent, device_bay. But I hope it's clear that those are the fields that seem to be having some issues. I will amend with some more detailed comments

pmsharp2 avatar Aug 19 '25 09:08 pmsharp2

I went back and did the full reproduction steps to make sure I wasn't missing anything and narrowed it down a bit more. The bad importing only seems to occur when "tags" are present in the import data. Even when device tags match child and parent the child devices are set as non-rack devices. I have amended my title and steps to reflect that.

pmsharp2 avatar Aug 19 '25 10:08 pmsharp2

This is a strange one, does seem to operate different without the tags - here is the csv comma separated as the tab separate is difficult without the tags:

role,manufacturer,device_type,status,site,location,name,rack,position,face,parent,device_bay
test_device,netbox,test-shelf,planned,SFO,DC1,test-shelf,A01,18,front,,
test_device,netbox,test-device,planned,SFO,DC1,test-device,A01,,,test-shelf,bay1

arthanson avatar Aug 21 '25 21:08 arthanson