Skip to content

Can't place multiple devices in rack with non-racked device (using API) #17810

Closed
@markusmarkusz

Description

@markusmarkusz

Deployment Type

Self-hosted

Triage priority

This is preventing me from using NetBox

NetBox Version

v4.1.4

Python Version

3.12

Steps to Reproduce

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

Important: I can only reproduce the problem using the REST API.

API Calls

# Create first device, non-racked in the rack (remember the id, ensure there are no devices non-racked before)
curl -X POST -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"device_type":116,"role":25,"site":1,"rack":168}' https://netbox.example.org/api/dcim/devices/ | jq .id
# Create second device, floating around in the site
curl -X POST -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"device_type":116,"role":25,"site":1}' https://netbox.example.org/api/dcim/devices/ | jq . | less
# Try moving the device to the rack of the first device non-racked (fails)
curl -X PATCH -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"rack":168}' https://netbox.example.org/api/dcim/devices/$ID_FROM_THE_FIRST_COMMAND/ | jq . | less
# Run first command again, creating another device, doesn't fail strangely
curl -X POST -H "authorization: Token TOKEN" -H 'Content-Type: application/json' -d '{"device_type":116,"role":25,"site":1,"rack":168}' https://netbox.example.org/api/dcim/devices/ | jq .id

Expected Behavior

Device should be placed in the rack as non-racked.

Observed Behavior

HTTP 400 Error Code

{"non_field_errors": ["The fields rack, position, face must make a unique set."]}

Metadata

Metadata

Assignees

Labels

netboxseverity: mediumResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions