Unable to place another device in rack non-racked via REST API #9850

Closed
opened 2025-12-29 21:23:31 +01:00 by adam · 11 comments
Owner

Originally created by @FestplattenSchnitzel on GitHub (Jun 15, 2024).

Originally assigned to: @arthanson on GitHub.

Deployment Type

Self-hosted

NetBox Version

4.1.5

Python Version

3.12.3

Steps to Reproduce

  1. Ensure some site exists
  2. Ensure some rack exists in the site (id=1 in example)
  3. Create first device in rack non-racked
  4. Create second device in the site (id=2 in example)
  5. Try placing the the device in the rack non-racked via the API

curl -X PATCH -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"rack":1}' https://netbox.example.org/api/dcim/devices/2/

Expected Behaviour

API request should be successful (HTTP 200), device should be placed in the rack non-racked.

Observed Behaviour

API request fails (HTTP 400), (formatting applied by me):

{
  "non_field_errors": [
    "The fields rack, position, face must make a unique set."
  ]
}
Originally created by @FestplattenSchnitzel on GitHub (Jun 15, 2024). Originally assigned to: @arthanson on GitHub. ### Deployment Type Self-hosted ### NetBox Version 4.1.5 ### Python Version 3.12.3 ### Steps to Reproduce 1. Ensure some site exists 2. Ensure some rack exists in the site (id=1 in example) 3. Create first device in rack non-racked 4. Create second device in the site (id=2 in example) 5. Try placing the the device in the rack non-racked via the API `curl -X PATCH -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"rack":1}' https://netbox.example.org/api/dcim/devices/2/` ### Expected Behaviour API request should be successful (HTTP 200), device should be placed in the rack non-racked. ### Observed Behaviour API request fails (HTTP 400), (formatting applied by me): ```json { "non_field_errors": [ "The fields rack, position, face must make a unique set." ] } ```
adam added the type: bugpending closurestatus: revisions neededseverity: low labels 2025-12-29 21:23:31 +01:00
adam closed this issue 2025-12-29 21:23:32 +01:00
Author
Owner

@FestplattenSchnitzel commented on GitHub (Jun 15, 2024):

This works fine via the UI though.

@FestplattenSchnitzel commented on GitHub (Jun 15, 2024): This works fine via the UI though.
Author
Owner

@v0tti commented on GitHub (Jun 17, 2024):

I believe you have to set the device position within the rack as well as the rack face in order to successfully add a device to a rack. That is also what the error message is trying to tell you.

@v0tti commented on GitHub (Jun 17, 2024): I believe you have to set the device `position` within the rack as well as the rack `face` in order to successfully add a device to a rack. That is also what the error message is trying to tell you.
Author
Owner

@jeremystretch commented on GitHub (Jun 17, 2024):

@v0tti is correct: Just as in the UI, you need to specify a unit and face when assigning a device to a rack. I'll leave this open for anyone who would like to work on improving the error message.

@jeremystretch commented on GitHub (Jun 17, 2024): @v0tti is correct: Just as in the UI, you need to specify a unit and face when assigning a device to a rack. I'll leave this open for anyone who would like to work on improving the error message.
Author
Owner

@FestplattenSchnitzel commented on GitHub (Jun 17, 2024):

I did not specify rack and position on purpose as the device should be "Not racked". Sorry I didn't state that clearer.

Using GET on a "Not racked" device returns null for both attributes. Explicitly providing both attributes at PATCH results in the same error.

Still: for me it's possible to not provide position and face to place a device in a rack "Not racked" in the UI.

@FestplattenSchnitzel commented on GitHub (Jun 17, 2024): I did not specify `rack` and `position` on purpose as the device should be "Not racked". Sorry I didn't state that clearer. Using GET on a "Not racked" device returns `null` for both attributes. Explicitly providing both attributes at PATCH results in the same error. Still: for me it's possible to not provide `position` and `face` to place a device in a rack "Not racked" in the UI.
Author
Owner

@arthanson commented on GitHub (Jun 17, 2024):

@FestplattenSchnitzel Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.0.5. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.

I tried with two different devices and used your curl command and in both cases it set the rack correctly without an error message (these did not have any rack assigned previously).

@arthanson commented on GitHub (Jun 17, 2024): @FestplattenSchnitzel Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.0.5. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data. I tried with two different devices and used your curl command and in both cases it set the rack correctly without an error message (these did not have any rack assigned previously).
Author
Owner

@FestplattenSchnitzel commented on GitHub (Jun 23, 2024):

Ah, I can reproduce this works fine with newly created sites and racks. However, if I create a new device in a site that exists for a long time™ already:

curl -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"role":1,"device_type":1,"site":1,"status":"planned"}' https://netbox.example.org/api/dcim/devices/

then try to place ("not racked") that in a rack in the same site (also exists since long ago):

curl -sX PATCH -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"rack":2}' https://netbox.example.org/api/dcim/devices/2222/

I get the error from the original comment.

@FestplattenSchnitzel commented on GitHub (Jun 23, 2024): Ah, I can reproduce this works fine with newly created sites and racks. However, if I create a new device in a site that exists for a long time™ already: `curl -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"role":1,"device_type":1,"site":1,"status":"planned"}' https://netbox.example.org/api/dcim/devices/` then try to place ("not racked") that in a rack in the same site (also exists since long ago): `curl -sX PATCH -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"rack":2}' https://netbox.example.org/api/dcim/devices/2222/` I get the error from the original comment.
Author
Owner

@FestplattenSchnitzel commented on GitHub (Jun 23, 2024):

OK, the problem is you can't place a second device in a rack non-racked when there is a first one already. The old racks all had at least one non-racked device contrary to the newly created ones, which explains the behaviour from my last comment.

With a little more creativity one could've guessed that at the very beginning … :D

Will update initial comment and title soon …

@FestplattenSchnitzel commented on GitHub (Jun 23, 2024): OK, the problem is you can't place a second device in a rack non-racked when there is a first one already. The old racks all had at least one non-racked device contrary to the newly created ones, which explains the behaviour from my last comment. With a little more creativity one could've guessed that at the very beginning … :D Will update initial comment and title soon …
Author
Owner

@github-actions[bot] commented on GitHub (Jul 1, 2024):

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 (Jul 1, 2024): 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 (Jul 10, 2024):

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 (Jul 10, 2024): 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.
Author
Owner

@mabezi commented on GitHub (Aug 21, 2024):

@arthanson could you please take another look at this? I can reproduce the error pattern too.
Due to the issue one of our applications no longer works.

@mabezi commented on GitHub (Aug 21, 2024): @arthanson could you please take another look at this? I can reproduce the error pattern too. Due to the issue one of our applications no longer works.
Author
Owner

@HappyFX commented on GitHub (Oct 3, 2024):

Same problem can't move device with rack and empty position and face

@HappyFX commented on GitHub (Oct 3, 2024): Same problem can't move device with `rack` and empty `position` and `face`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9850