-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Removal of an option in a CustomFieldChoice does not update objects with the choiceset and the option selected #17558
Comments
This should throw a validation error if you try to delete a choice and there are items assigned to that choice. |
just my 0.02 cents, I prefer the exiting method. Removing a choice set doesn't make the choices selection on each object automatically invalid. It just means it's no longer available as a selection. |
I think I agree with @goteamkor -- I can think of a lot of use cases where you would want to retain the data from a time when an option was available, but have that option not be available to select anymore. Like if you had a list of "Supported Devices" and you had previously assigned a value from that list to a "device" field on some other model; and then that device becomes no longer supported, so you remove it from the list. I'd much rather have the device field stay filled in, to preserve the history of that object, and allow the freedom to define the custom field choices such that that device is no longer offered as "supported". |
It does, by definition. Attempting to re-save an object with a selected choice that is no longer available will fail (or nullify that choice, depending on the mechanism). Allowing invalid choices to be defined would defeat the purpose of defining a set of choices in the first place. |
We're not talking about opening the object and trying to save it again with the same value that is no longer a valid option. I'm talking specifically about the FR here, which is to alter the behavior of what happens when removing an option from a choice set. The proposed change would make the removal of an option from a choiceset set fail when trying to save because there are objects out there that still reference that option. You shouldn't have to go remove every reference to the option before netbox will let you remove the option from the choice set. Basically what I'm advocating here is that existing behavior is maintained. I disagree with @arthanson that a validation error should be thrown when trying to remove an option from a choice set when objects reference that option. And I also disagree with @cruse1977 that when removing the option, all objects that reference that option should change to "null/none" EDIT: I see there is already a pull request created. (#17591) I hope this doesn't get merged. |
Deployment Type
NetBox Cloud
NetBox Version
v4.1.1
Python Version
3.12
Steps to Reproduce
Expected Behavior
The selected option on the choiceset attached to device Z should be null/none, due to the option removal
Observed Behavior
Option B remains until the object is edited or saved, despite no longer existing.
Note - Due to the options inherent within ChoiceSets (eg: Non Null, default etc) but I'm trying to ascertain if this is a bug (ie: NetBox should warn/error on Objects with this choice selected) or expected behaviour - hence requesting feedback
The text was updated successfully, but these errors were encountered: