Inconsistency in API for field role/device #4898

Closed
opened 2025-12-29 19:21:54 +01:00 by adam · 7 comments
Owner

Originally created by @leahoswald on GitHub (May 11, 2021).

Originally assigned to: @abhi1693 on GitHub.

NetBox version

v2.9.9

Python version

3.6

Steps to Reproduce

  • Open a VM in the API view: The role field is called role
  • Open a device in the API view: The role field is called device_role

Expected Behavior

I would expect that both fields are called the same (role) because they are linking to the same data.

Observed Behavior

The device field is called device_role and the VM field is called role

Originally created by @leahoswald on GitHub (May 11, 2021). Originally assigned to: @abhi1693 on GitHub. ### NetBox version v2.9.9 ### Python version 3.6 ### Steps to Reproduce - Open a VM in the API view: The role field is called `role` - Open a device in the API view: The role field is called `device_role` ### Expected Behavior I would expect that both fields are called the same (`role`) because they are linking to the same data. ### Observed Behavior The device field is called `device_role` and the VM field is called `role`
adam added the status: acceptedtype: housekeeping labels 2025-12-29 19:21:54 +01:00
adam closed this issue 2025-12-29 19:21:54 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 12, 2021):

It doesn't seem like the hassle of introducing a breaking change like this would be worthwhile just to achieve consistency with another model.

@jeremystretch commented on GitHub (May 12, 2021): It doesn't seem like the hassle of introducing a breaking change like this would be worthwhile just to achieve consistency with another model.
Author
Owner

@leahoswald commented on GitHub (May 12, 2021):

Of course it's a breaking change. On the other hand it means extra handling for every code that works with both devices and VMs. For example if you want to generate monitoring config from it. I understand that it is to much for a normal release but maybe if there is a future release with other braking changes it would be an opportunity to fix it. It would be the first braking change on the API (I remember fixing some code because of a change in the state variable.)

@leahoswald commented on GitHub (May 12, 2021): Of course it's a breaking change. On the other hand it means extra handling for every code that works with both devices and VMs. For example if you want to generate monitoring config from it. I understand that it is to much for a normal release but maybe if there is a future release with other braking changes it would be an opportunity to fix it. It would be the first braking change on the API (I remember fixing some code because of a change in the `state` variable.)
Author
Owner

@jeremystretch commented on GitHub (May 12, 2021):

On the other hand it means extra handling for every code that works with both devices and VMs.

These are always going to require separate logic, as they are different models. Renaming the device_role field won't change that.

@jeremystretch commented on GitHub (May 12, 2021): > On the other hand it means extra handling for every code that works with both devices and VMs. These are always going to require separate logic, as they are different models. Renaming the `device_role` field won't change that.
Author
Owner

@jeremystretch commented on GitHub (May 18, 2021):

Flagging this for milestone assignment to potentially handle in the future. We could potentially implement a getter & setter to maintain backward compatibility across releases, however I'm not sure what potential pitfalls we'd run into regarding Django's ORM's behavior.

@jeremystretch commented on GitHub (May 18, 2021): Flagging this for milestone assignment to potentially handle in the future. We could potentially implement a getter & setter to maintain backward compatibility across releases, however I'm not sure what potential pitfalls we'd run into regarding Django's ORM's behavior.
Author
Owner

@abhi1693 commented on GitHub (Jan 14, 2023):

Would it fine if a field is renamed and this is introduced as a breaking change for v3.5? I can submit a PR if that's accepted as a solution

@abhi1693 commented on GitHub (Jan 14, 2023): Would it fine if a field is renamed and this is introduced as a breaking change for v3.5? I can submit a PR if that's accepted as a solution
Author
Owner

@ryanmerolle commented on GitHub (Apr 25, 2023):

This could be a good candidate for 3.6

@ryanmerolle commented on GitHub (Apr 25, 2023): This could be a good candidate for 3.6
Author
Owner

@abhi1693 commented on GitHub (Aug 2, 2023):

I'm going to try to make the field backward-compaitible for the API and ORM access. If that's possible, should be able to ship this with v3.6

@abhi1693 commented on GitHub (Aug 2, 2023): I'm going to try to make the field backward-compaitible for the API and ORM access. If that's possible, should be able to ship this with v3.6
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4898