Netbox: NetBox 2.9 custom field selection changelog change between WebUI and API

Created on 10 Sep 2020  路  12Comments  路  Source: netbox-community/netbox

Environment

  • Python version: 3.6.9
  • NetBox version: 2.9.3

Steps to Reproduce

  1. create a custom field type selection with some values
  2. create a device
  3. set the custom field on the device in the WebUI: the changelog shows the custom field value
  4. change the device status with a API patch request: the changelog shows a custom field value change from value to label

Expected Behavior

The changelog for custom fields of type selection shows always the label, as in NetBox before 2.9

Observed Behavior

The changelog for custom fields of type selection show on WebUI changes the value and on API changes the label (even if the custom field value wasn't changed by the API request).

Changelog of custom field value set via WebUI, custom field value (1) is shown:
netbox_webui_custom_field_value_change

Changelog of status change via API patch request, custom field changes from value (1) to label (D):
netbox_api_status_change

accepted bug

All 12 comments

Thank you for opening a bug report. I was unable to reproduce the reported behavior on the current develop branch: Updating the field via both the web UI and the REST API result in the changelog representation showing the integer value. This was likely changed during work on #5109.

I'm going to close this out as I'm fairly confident it's already been fixed in development, but please ask that it be re-opened if you continue to experience the issue on v2.9.4.

@jeremystretch any chances to restore the old behavior from NetBox 2.8 to show the custom field choice label in the changelog?
Because it is hard to review a change in the changelog if you only see the integer IDs of the custom field choices.

Custom fields are being overhauled under #4878, so the entire data model will change in v2.10.

@jeremystretch I still can replicate this in 2.9.4

curl -sX PATCH -H "Authorization: Token $NETBOX_API_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json; indent=2" "$NETBOX_URL/api/dcim/devices/109/" --data '{"status": "active"}'

netbox_api_status_change

Just to make it clear, I just changed the status by the API request, but the custom field project_status changed from value to label (besides the status change) in the changelog.

@jeremystretch can you please re-open this issue as I still can replicate the problem in 2.9.4.

FYI custom fields have been overhauled entirely for v2.10, so it's likely this won't be addressed in v2.9.

@jeremystretch I can confirm that I don't see this problem in v2.10

I have also found with git bisect the commit that introduced this problem: dd707c97af7df048db7bb659fa11bc8002115804.
Would be great if you would find time to fix this for v2.9.

@cloos would you like to volunteer to take ownership of this issue?

@jeremystretch I think I found the problem and can create a PR for this.

@jeremystretch I have so far added tests and fixed it for WebUI create and update and API update, but I can't find the place where the cf values are cached for the API create request. Maybe you can give me a hint.

@jeremystretch as NetBox 2.10 is released, this issue is no longer present and can be closed.

But I would like to provide the tests I have created, so this issue will never happen again.
Can we change the purpose if this issue or should I create a new one for the tests?

@cloos You can add a PR to add the tests. I'll leave this issue open to be "fixed" by the PR. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

billyzoellers picture billyzoellers  路  3Comments

benjy44 picture benjy44  路  3Comments

candlerb picture candlerb  路  3Comments

shugotek picture shugotek  路  3Comments

aarjbdea picture aarjbdea  路  3Comments