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

Closed
markusmarkusz opened this issue Oct 18, 2024 · 5 comments · Fixed by #18162
Closed

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

markusmarkusz opened this issue Oct 18, 2024 · 5 comments · Fixed by #18162
Assignees
Labels
netbox severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for 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 status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: revisions needed This issue requires additional information to be actionable status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Oct 23, 2024
@bctiemann
Copy link
Contributor

I tried adding default=None to the face and position model fields on Device (as recommended in that DRF thread) but it doesn't seem to help.

It's possible it's not exactly the same issue as that DRF bug, or a different side effect of the same change, but in either case it's unclear whether the DRF behavior will be reverted or if this is a breaking change that they will stick with.

@jeremystretch jeremystretch added the netbox label Nov 1, 2024 — with Linear
@markusmarkusz
Copy link
Author

Would it be an option to downgrade the Django REST Framework to an older version? If I got it correctly from the issue, a fix is at the moment not in sight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
netbox severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
3 participants