Misleading error message when attempting to assign an already assigned device to a device bay with CSV import #10750

Closed
opened 2025-12-29 21:35:32 +01:00 by adam · 4 comments
Owner

Originally created by @deliciouslytyped on GitHub (Feb 8, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.2.2 with netbox-docker.
I have the branching plugin installed in case that changes anything. I haven't tried to repro without the plugin.

Python Version

3.11

Steps to Reproduce

I'm not going to write down all the steps to create the entire data hierarchy. I did this by hand because I'm new and still figuring out netbox.

  1. Create a device with a device bay
  2. Assign a device to the device bay
  3. Attempt to assign device bay using tab separated CSV import (because that's what comes from LibreOffice copy-paste) with something like:
device	name	label	installed_device	description	id	tags
mydev	slot0		myotherdev		130	new

Expected Behavior

The assignment succeeds because it's a no-op and doesn't change anything, not blocking the rest of the rows from being processed.
Either that or an error message describing the more comprehensible problem, but then this is makes batch processing via CSV import unusable.

Observed Behavior

This error ("child device not found") is shown on attempting the import:
Image

If I remove the device from the bay, (and it ends up back in the unracked devices list) the import succeeds.

The relevant code:
f845b2cf07/netbox/dcim/forms/bulk_import.py (L1057-L1066)

I assume this pattern is present elsewhere as well.

Originally created by @deliciouslytyped on GitHub (Feb 8, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.2.2 with netbox-docker. I have the branching plugin installed in case that changes anything. I haven't tried to repro without the plugin. ### Python Version 3.11 ### Steps to Reproduce I'm not going to write down all the steps to create the entire data hierarchy. I did this by hand because I'm new and still figuring out netbox. 1. Create a device with a device bay 2. Assign a device to the device bay 3. Attempt to assign device bay using tab separated CSV import (because that's what comes from LibreOffice copy-paste) with something like: ``` device name label installed_device description id tags mydev slot0 myotherdev 130 new ``` ### Expected Behavior The assignment succeeds because it's a no-op and doesn't change anything, not blocking the rest of the rows from being processed. Either that or an error message describing the more comprehensible problem, but then this is makes batch processing via CSV import unusable. ### Observed Behavior This error ("child device not found") is shown on attempting the import: ![Image](https://github.com/user-attachments/assets/a999f0a8-97cc-4959-874a-17f9c668c2e3) If I remove the device from the bay, (and it ends up back in the unracked devices list) the import succeeds. The relevant code: https://github.com/netbox-community/netbox/blob/f845b2cf07cd65a109c46632a2540d3647c1c492/netbox/dcim/forms/bulk_import.py#L1057-L1066 I assume this pattern is present elsewhere as well.
adam added the type: bugpending closurestatus: revisions needed labels 2025-12-29 21:35:32 +01:00
adam closed this issue 2025-12-29 21:35:32 +01:00
Author
Owner

@deliciouslytyped commented on GitHub (Feb 8, 2025):

Looking closer at the code, I guess the issue is that a selection field can have an "invalid choice" when a choice doesn't exist both for the reason that it's already selected and for the reason that the target object doesn't exist.

When specifying an ID during CSV import, when there are no changed, the operation should succeed. This is probably a wider CSV(?)ModelChoiceField issue.

@deliciouslytyped commented on GitHub (Feb 8, 2025): Looking closer at the code, I guess the issue is that a selection field can have an "invalid choice" when a choice doesn't exist both for the reason that it's already selected and for the reason that the target object doesn't exist. When specifying an ID during CSV import, when there are no changed, the operation should succeed. This is probably a wider CSV(?)ModelChoiceField issue.
Author
Owner

@arthanson commented on GitHub (Feb 18, 2025):

@deliciouslytyped can you please provide a more step-by-step reproduction scenario:

  1. Create Device Role: xxx (specify any needed fields)
  2. Create Device Type: yyy
  3. Create Device: role=xxx, device type=yyy

We get a lot of issues in and it really helps the maintainers try to quickly reproduce an issue instead of having to guess at reproduction steps or potentially not reproduce the problem correctly.

@arthanson commented on GitHub (Feb 18, 2025): @deliciouslytyped can you please provide a more step-by-step reproduction scenario: 1. Create Device Role: xxx (specify any needed fields) 2. Create Device Type: yyy 3. Create Device: role=xxx, device type=yyy We get a lot of issues in and it really helps the maintainers try to quickly reproduce an issue instead of having to guess at reproduction steps or potentially not reproduce the problem correctly.
Author
Owner

@github-actions[bot] commented on GitHub (Feb 26, 2025):

This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.

@github-actions[bot] commented on GitHub (Feb 26, 2025): This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 6, 2025):

This issue is being closed as no further information has been provided. If you would like to revisit this topic, please first modify your original post to include all the requested detail, and then ask that the issue be reopened.

@github-actions[bot] commented on GitHub (Mar 6, 2025): This issue is being closed as no further information has been provided. If you would like to revisit this topic, please first modify your original post to include all the requested detail, and then ask that the issue be reopened.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10750