Custom field type boolean changelog representation change #4443

Closed
opened 2025-12-29 18:36:01 +01:00 by adam · 3 comments
Owner

Originally created by @netsandbox on GitHub (Jan 6, 2021).

Environment

  • Python version: 3.6.9
  • NetBox version: 2.10.3 (upgrade from 2.8.9)

Steps to Reproduce

  1. create a boolean custom field for virtual-machine in NetBox before 2.10.0
  2. create a virtual-machine and set the boolean custom field value to True
  3. upgrade NetBox to 2.10.3
  4. go to the previously created virtual-machine, click Edit and then Update without making any changes

Expected Behavior

No changelog record is created.
Or more correct a changelog record is created without showing a change, because currently NetBox still creates a changelog record even if nothing changed.

Observed Behavior

A changelog record is created who shows a value change from "True" to true:

NetBox_change_bool_cf

So every time you change a object which has a boolean custom field assigned you get a unrelated change of the boolean custom field value.

This is a result of the Reimplementation of Custom Fields (#4878).

Maybe it is possible to avoid these changes.

Originally created by @netsandbox on GitHub (Jan 6, 2021). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reporting reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, please start a discussion instead: https://github.com/netbox-community/netbox/discussions Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.6.9 * NetBox version: 2.10.3 (upgrade from 2.8.9) <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. create a boolean custom field for virtual-machine in NetBox **before** 2.10.0 2. create a virtual-machine and set the boolean custom field value to True 3. upgrade NetBox to 2.10.3 4. go to the previously created virtual-machine, click `Edit` and then `Update` **without** making any changes <!-- What did you expect to happen? --> ### Expected Behavior No changelog record is created. Or more correct a changelog record is created without showing a change, because currently NetBox still creates a changelog record even if nothing changed. <!-- What happened instead? --> ### Observed Behavior A changelog record is created who shows a value change from `"True"` to `true`: ![NetBox_change_bool_cf](https://user-images.githubusercontent.com/165430/103805271-a5da8000-5053-11eb-9e68-9ff32529aff1.png) So every time you change a object which has a boolean custom field assigned you get a unrelated change of the boolean custom field value. This is a result of the Reimplementation of Custom Fields (#4878). Maybe it is possible to avoid these changes.
adam closed this issue 2025-12-29 18:36:01 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 7, 2021):

This happens because the old custom fields implementation stored booleans (and all other values) as strings, whereas the new one does not. The same behavior likely happens for integers as well. What fix would you propose?

@jeremystretch commented on GitHub (Jan 7, 2021): This happens because the old custom fields implementation stored booleans (and all other values) as strings, whereas the new one does not. The same behavior likely happens for integers as well. What fix would you propose?
Author
Owner

@netsandbox commented on GitHub (Jan 7, 2021):

I think one option to fix this is to update the records in the extras_objectchange table (convert custom field boolean values from string to bool), which maybe could result in a much longer upgrade for NetBox instances with many change records.

Another option would be to cast the custom field boolean values to bool in the WebUI and API when they are displayed or fetched.

But both options could have some side effects, because you can change the type of a custom field e.g. from text to bool, so if the type is now bool, this doesn't mean that all values should be presented as bool.
So I think there isn't much we can do here.

@netsandbox commented on GitHub (Jan 7, 2021): I think one option to fix this is to update the records in the `extras_objectchange` table (convert custom field boolean values from string to bool), which maybe could result in a much longer upgrade for NetBox instances with many change records. Another option would be to cast the custom field boolean values to bool in the WebUI and API when they are displayed or fetched. But both options could have some side effects, because you can change the type of a custom field e.g. from text to bool, so if the type is now bool, this doesn't mean that all values should be presented as bool. So I think there isn't much we can do here.
Author
Owner

@jeremystretch commented on GitHub (Jan 19, 2021):

It's not ideal but IMO the best option is to just let it be. Eventually it will no longer be an issue as expired change log data gets scrubbed.

@jeremystretch commented on GitHub (Jan 19, 2021): It's not ideal but IMO the best option is to just let it be. Eventually it will no longer be an issue as expired change log data gets scrubbed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4443