Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
markusmarkusz opened this issue Oct 18, 2024 · 3 comments
Open
Labels
status: under review Further discussion is needed to determine this issue's scope and/or implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@markusmarkusz
Copy link

markusmarkusz commented Oct 18, 2024

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."]}
@markusmarkusz markusmarkusz added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Oct 18, 2024
@jeremystretch
Copy link
Member

Please revise your post above to include the specific attributes of the devices you're creating and the API requests you're sending.

@jeremystretch jeremystretch added status: revisions needed This issue requires additional information to be actionable and removed status: needs triage This issue is awaiting triage by a maintainer labels Oct 18, 2024
@markusmarkusz
Copy link
Author

Hello @jeremystretch, thank you for your response. I adjusted my post and added the API calls.

@jeremystretch
Copy link
Member

I was able to replicate this. The bug seems to stem from the absence of the face and position fields in the PATCH data. This looks related to a bug in Django REST Framework 3.15, but I haven't been able to dig further yet.

@jeremystretch jeremystretch added status: under review Further discussion is needed to determine this issue's scope and/or implementation and removed status: revisions needed This issue requires additional information to be actionable labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: under review Further discussion is needed to determine this issue's scope and/or implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants