Inventory Item editing problem #6756

Closed
opened 2025-12-29 19:45:00 +01:00 by adam · 6 comments
Owner

Originally created by @nmisaki on GitHub (Aug 2, 2022).

NetBox version

v3.2.7

Python version

3.10

Steps to Reproduce

  1. Click "Edit" button on any inventory item which associated with Device A / Interface A
  2. Change device field to Device B
  3. Click "Save" button

Expected Behavior

"Component" link should be changed to Device B

Observed Behavior

"Component" link was Device A / Interface A

Originally created by @nmisaki on GitHub (Aug 2, 2022). ### NetBox version v3.2.7 ### Python version 3.10 ### Steps to Reproduce 1. Click "Edit" button on any inventory item which associated with _Device A / Interface A_ 2. Change device field to _Device B_ 3. Click "Save" button ### Expected Behavior "Component" link should be changed to _Device B_ ### Observed Behavior "Component" link was _Device A / Interface A_
adam added the type: bug label 2025-12-29 19:45:00 +01:00
adam closed this issue 2025-12-29 19:45:00 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Aug 2, 2022):

"Component" link should be changed to Device B

Should it? I agree that there is a bug here as moving an interface item with a link to a component leaves it in an inconsistant state, but how would moving it work? We can't just move the component to the other device. We also can't just find a component with the same name reliably.

One of the following might be a solution:

  1. Reject when saving with an error indicating that it's not possible to move inventory items that have a link to a component.
  2. Remove the link when moving an inventory item.

The inventory item -> component link is a little weird to begin with though, as there is no way to "unlink" them without deleting the inventory item afaik. Not sure what the correct solution is here.

@kkthxbye-code commented on GitHub (Aug 2, 2022): > "Component" link should be changed to Device B Should it? I agree that there is a bug here as moving an interface item with a link to a component leaves it in an inconsistant state, but how would moving it work? We can't just move the component to the other device. We also can't just find a component with the same name reliably. One of the following might be a solution: 1. Reject when saving with an error indicating that it's not possible to move inventory items that have a link to a component. 2. Remove the link when moving an inventory item. The inventory item -> component link is a little weird to begin with though, as there is no way to "unlink" them without deleting the inventory item afaik. Not sure what the correct solution is here.
Author
Owner

@DanSheps commented on GitHub (Sep 1, 2022):

The "device" field is simply a filter field, it is not an accurate reflection of the current device. If you change the device and then select the component dropdown it should populate it with components from the new device that you can select, but you must select one of those new componets.

@DanSheps commented on GitHub (Sep 1, 2022): The "device" field is simply a filter field, it is not an accurate reflection of the current device. If you change the device and then select the component dropdown it should populate it with components from the new device that you can select, but you must select one of those new componets.
Author
Owner

@kkthxbye-code commented on GitHub (Sep 1, 2022):

@DanSheps - I'm not sure I follow Dan. Are you saying it should be like that or that it is? Because Device is definitely not just a filter field in this case, it decides the device field of the InventoryItem model. It is also possible to update the device of the InventoryItem through the API, are you saying that this is unintended as well?

it is not an accurate reflection of the current device

I mean it is here, which is what causes the bug as it is neither synchronized with the parent component or validated against it.

@kkthxbye-code commented on GitHub (Sep 1, 2022): @DanSheps - I'm not sure I follow Dan. Are you saying it should be like that or that it is? Because Device is definitely not just a filter field in this case, it decides the device field of the [InventoryItem model](https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/models/device_components.py#L43-L51). It is also possible to update the device of the InventoryItem through the API, are you saying that this is unintended as well? > it is not an accurate reflection of the current device I mean it is here, which is what causes the bug as it is neither synchronized with the parent component or validated against it.
Author
Owner

@DanSheps commented on GitHub (Sep 1, 2022):

You are right, going to blame that on me being a rush to get to dinner. Forgot that it was also a component model.

Anyways, we don't allow changing front port/rear port/interface, that could be part of the bug. However Inventory is a lititle different in that often it is a removeable so perhaps we should allow changes; however there is no way to re-associate it to another component from what I can tell, in the GUI. It is also likely that it is intended to not be moveable based on the behaviour we are seeing.

Based on this I would say, for now we should raise a error that it is not moveable.

@DanSheps commented on GitHub (Sep 1, 2022): You are right, going to blame that on me being a rush to get to dinner. Forgot that it was also a component model. Anyways, we don't allow changing front port/rear port/interface, that could be part of the bug. However Inventory is a lititle different in that often it is a removeable so perhaps we should allow changes; however there is no way to re-associate it to another component from what I can tell, in the GUI. It is also likely that it is intended to not be moveable based on the behaviour we are seeing. Based on this I would say, for now we should raise a error that it is not moveable.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 1, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Nov 1, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (Nov 17, 2022):

As of NetBox v3.3.8 it's not possible to change the device to which an inventory item is assigned, so this can no longer be reproduced. Please see #10447 for further discussion relating to this functionality.

@jeremystretch commented on GitHub (Nov 17, 2022): As of NetBox v3.3.8 it's not possible to change the device to which an inventory item is assigned, so this can no longer be reproduced. Please see #10447 for further discussion relating to this functionality.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6756