Incorrect handling of null value in custom fields #4655

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

Originally created by @karlism on GitHub (Mar 12, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.10.6

Python version

3.6

Steps to Reproduce

  1. Have existing custom field with empty value (in my case it's dcim > device custom field)
  2. Update from NetBox 2.9.11 to 2.10.6
  3. Add new device and leave this custom field empty while creating it
  4. Value of this custom field will be "" (empty string) instead of null

Expected Behavior

Value of empty custom fields should be null

Observed Behavior

Value of empty custom fields is "" (empty string). Devices that have been added prior to update to NetBox 2.10.6, still have proper value null for empty custom fields.

Originally created by @karlism on GitHub (Mar 12, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.10.6 ### Python version 3.6 ### Steps to Reproduce 1. Have existing custom field with empty value (in my case it's dcim > device custom field) 2. Update from NetBox 2.9.11 to 2.10.6 3. Add new device and leave this custom field empty while creating it 4. Value of this custom field will be "" (empty string) instead of `null` ### Expected Behavior Value of empty custom fields should be null ### Observed Behavior Value of empty custom fields is "" (empty string). Devices that have been added prior to update to NetBox 2.10.6, still have proper value `null` for empty custom fields.
adam added the type: bugstatus: accepted labels 2025-12-29 19:19:12 +01:00
adam closed this issue 2025-12-29 19:19:12 +01:00
Author
Owner

@karlism commented on GitHub (Mar 12, 2021):

All following operations are performed in NetBox 2.10.6.

To demonstrate this bit better, existing device that has been created prior to upgrade to NetBox 2.10.6:

    "custom_fields": {
        "ansible_groups": "esxi_vms,virtual,letsencrypt,awx_nodes",
        "ansible_python_interpreter": null,
        "environment": "development"
    },

New device that has been added in NetBox 2.10.6 (no changes have been made to custom fields):

    "custom_fields": {
        "ansible_groups": "esxi_vms,virtual,feproxy",
        "ansible_python_interpreter": "",
        "environment": "development"
    },

Now I will create new custom field with default null value:
image
Lets check previous device again:

    "custom_fields": {
        "ansible_groups": "esxi_vms,virtual,feproxy",
        "ansible_python_interpreter": "",
        "environment": "development",
        "test": null
    },

Now add new device again:
image

    "custom_fields": {
        "ansible_groups": "some,groups,here",
        "ansible_python_interpreter": "",
        "environment": "development",
        "test": ""
    },
@karlism commented on GitHub (Mar 12, 2021): All following operations are performed in NetBox 2.10.6. To demonstrate this bit better, existing device that has been created prior to upgrade to NetBox 2.10.6: ``` "custom_fields": { "ansible_groups": "esxi_vms,virtual,letsencrypt,awx_nodes", "ansible_python_interpreter": null, "environment": "development" }, ``` New device that has been added in NetBox 2.10.6 (no changes have been made to custom fields): ``` "custom_fields": { "ansible_groups": "esxi_vms,virtual,feproxy", "ansible_python_interpreter": "", "environment": "development" }, ``` Now I will create new custom field with default `null` value: ![image](https://user-images.githubusercontent.com/19568035/110899982-4eca8300-8302-11eb-9146-8c76034b86e7.png) Lets check previous device again: ``` "custom_fields": { "ansible_groups": "esxi_vms,virtual,feproxy", "ansible_python_interpreter": "", "environment": "development", "test": null }, ``` Now add new device again: ![image](https://user-images.githubusercontent.com/19568035/110900188-a79a1b80-8302-11eb-8a16-505b75ae1591.png) ``` "custom_fields": { "ansible_groups": "some,groups,here", "ansible_python_interpreter": "", "environment": "development", "test": "" }, ```
Author
Owner

@karlism commented on GitHub (Apr 22, 2021):

Just upgraded to NetBox 2.11.1 and behavior is same, I think this is also related to this issue: https://github.com/netbox-community/netbox/issues/6217

@karlism commented on GitHub (Apr 22, 2021): Just upgraded to NetBox 2.11.1 and behavior is same, I think this is also related to this issue: https://github.com/netbox-community/netbox/issues/6217
Author
Owner

@github-actions[bot] commented on GitHub (Jun 22, 2021):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jun 22, 2021): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@karlism commented on GitHub (Jul 8, 2021):

I guess that this issue is also related: https://github.com/netbox-community/netbox/issues/6686

@karlism commented on GitHub (Jul 8, 2021): I guess that this issue is also related: https://github.com/netbox-community/netbox/issues/6686
Author
Owner

@karlism commented on GitHub (Aug 24, 2021):

@jeremystretch, thanks! Just upgraded NetBox to 2.11.12 and verified that it is working properly now.

Any suggestions on how to fix all previously created devices that have "" instead of null value?

@karlism commented on GitHub (Aug 24, 2021): @jeremystretch, thanks! Just upgraded NetBox to 2.11.12 and verified that it is working properly now. Any suggestions on how to fix all previously created devices that have `""` instead of `null` value?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4655