Custom Field Multiple Selection losing value when bulk editing and adding a tag #5703

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

Originally created by @alinmear on GitHub (Nov 22, 2021).

NetBox version

v2.11.6

Python version

3.7

Steps to Reproduce

Objects created

  • Create a Virtualization Cluster Type

    {
        "id": 16,
        "url": "https://mynetbox.mydomain/api/virtualization/cluster-types/16/",
        "display": "TestType0",
        "name": "TestType0",
        "slug": "testtype0",
        "description": "",
        "custom_fields": {},
        "cluster_count": 0
    }
    
  • Create a Virtualization Testcluster

    {
        "id": 56,
        "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/",
        "display": "TestCluster0",
        "name": "TestCluster0",
        "type": {
            "id": 16,
            "url": "https://mynetbox.mydomain/api/virtualization/cluster-types/16/",
            "display": "TestType0",
            "name": "TestType0",
            "slug": "testtype0"
        },
        "group": null,
        "tenant": null,
        "site": null,
        "comments": "",
        "tags": [],
        "custom_fields": {
            "Monitoring": "Auto",
            "mlagLacpMac": ""
        },
        "device_count": 0,
        "virtualmachine_count": 0
    }
    
  • Create VM0

    {
        "id": 5210,
        "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5210/",
        "display": "TESTVM0",
        "name": "TestVM0",
        "status": {
            "value": "active",
            "label": "Active"
        },
        "site": null,
        "cluster": {
            "id": 56,
            "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/",
            "display": "TestCluster0",
            "name": "TestCluster0"
        },
        "role": null,
        "tenant": null,
        "platform": null,
        "primary_ip": null,
        "primary_ip4": null,
        "primary_ip6": null,
        "vcpus": null,
        "memory": null,
        "disk": null,
        "comments": "",
        "local_context_data": null,
        "tags": [],
        "custom_fields": {},
        "config_context": null,
    }
    
  • Create VM1

    {
        "id": 5211,
        "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5211/",
        "display": "TESTVM1",
        "name": "TESTVM1",
        "status": {
            "value": "active",
            "label": "Active"
        },
        "site": null,
        "cluster": {
            "id": 56,
            "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/",
            "display": "TestCluster0",
            "name": "TestCluster0"
        },
        "role": null,
        "tenant": null,
        "platform": null,
        "primary_ip": null,
        "primary_ip4": null,
        "primary_ip6": null,
        "vcpus": null,
        "memory": null,
        "disk": null,
        "comments": "",
        "local_context_data": null,
        "tags": [],
        "custom_fields": {},
        "config_context": null,
    }
    
  • Create TestTag

    {
        "id": 26,
        "url": "https://mynetbox.mydomain/api/extras/tags/26/",
        "display": "TESTTag0",
        "name": "TESTTag0",
        "slug": "testtag0",
        "color": "9e9e9e",
        "description": "",
        "tagged_items": 0
    }
    
  • Create CustomField

    • Type: Multiple selection
    • Name: TestCF
    • Weight: 100
    • Label:
    • Description
    • Required: False
    • Default: null
    • Filter logic: Loose
    • Content types:
      • Virtualization > virtual machine
    • Minimum value:
    • Maximum value:
    • Validation regex:
    • Choices: choice1,choice2,choice3,choiceN
  • Update VM0 with new custom_field

    {
        "id": 5210,
        "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5210/",
        "display": "TESTVM0",
        "name": "TestVM0",
        "status": {
            "value": "active",
            "label": "Active"
        },
        "site": null,
        "cluster": {
            "id": 56,
            "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/",
            "display": "TestCluster0",
            "name": "TestCluster0"
        },
        "role": null,
        "tenant": null,
        "platform": null,
        "primary_ip": null,
        "primary_ip4": null,
        "primary_ip6": null,
        "vcpus": null,
        "memory": null,
        "disk": null,
        "comments": "",
        "local_context_data": null,
        "tags": [],
        "custom_fields": {
              "TestCF": [
                "choice1",
                "choice2"
              ]
        },
        "config_context": null,
    }
    
  • Update VM1 with new custom_fields

    {
        "id": 5211,
        "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5211/",
        "display": "TESTVM1",
        "name": "TESTVM1",
        "status": {
            "value": "active",
            "label": "Active"
        },
        "site": null,
        "cluster": {
            "id": 56,
            "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/",
            "display": "TestCluster0",
            "name": "TestCluster0"
        },
        "role": null,
        "tenant": null,
        "platform": null,
        "primary_ip": null,
        "primary_ip4": null,
        "primary_ip6": null,
        "vcpus": null,
        "memory": null,
        "disk": null,
        "comments": "",
        "local_context_data": null,
        "tags": [],
        "custom_fields": {
            "TestCF": [
                "choice1",
                "choice2"
            ]
        },
        "config_context": null,
    }
    

Steps

  • Go to virtualization/virtual-machines
  • Search for VMS: TESTVM
  • Press "Refine Search"
  • Check the two VMs TESTVM0 and TESTVM1
  • Press "Edit Selected"
  • Select the field of "Add tags"
  • Search and Enter "TESTTag0"
  • Press "Apply"

Expected Behavior

The Tag will be added to the selected vms, but the custom_field "TestCF will be untouched.

Observed Behavior

The custom_field "TestCF" is an empty list.

VMS Aftert this action:

  • VM0

    {
        "id": 5210,
        "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5210/",
        "display": "TESTVM0",
        "name": "TestVM0",
        "status": {
            "value": "active",
            "label": "Active"
        },
        "site": null,
        "cluster": {
            "id": 56,
            "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/",
            "display": "TestCluster0",
            "name": "TestCluster0"
        },
        "role": null,
        "tenant": null,
        "platform": null,
        "primary_ip": null,
        "primary_ip4": null,
        "primary_ip6": null,
        "vcpus": null,
        "memory": null,
        "disk": null,
        "comments": "",
        "local_context_data": null,
        "tags": [
            {
                "id": 26,
                "url": "https://mynetbox.mydomain/api/extras/tags/26/",
                "display": "TESTTag0",
                "name": "TESTTag0",
                "slug": "testtag0",
                "color": "9e9e9e"
            }
        ],
        "custom_fields": {
              "TestCF": []
        },
        "config_context": null,
    }
    
  • VM1

    
    
      #+begin_src json
    {
        "id": 5211,
        "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5211/",
        "display": "TESTVM1",
        "name": "TESTVM1",
        "status": {
            "value": "active",
            "label": "Active"
        },
        "site": null,
        "cluster": {
            "id": 56,
            "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/",
            "display": "TestCluster0",
            "name": "TestCluster0"
        },
        "role": null,
        "tenant": null,
        "platform": null,
        "primary_ip": null,
        "primary_ip4": null,
        "primary_ip6": null,
        "vcpus": null,
        "memory": null,
        "disk": null,
        "comments": "",
        "local_context_data": null,
        "tags": [
            {
                "id": 26,
                "url": "https://mynetbox.mydomain/api/extras/tags/26/",
                "display": "TESTTag0",
                "name": "TESTTag0",
                "slug": "testtag0",
                "color": "9e9e9e"
            }
        ],
        "custom_fields": {
            "TestCF": []
        },
        "config_context": null,
    }
    
Originally created by @alinmear on GitHub (Nov 22, 2021). ### NetBox version v2.11.6 ### Python version 3.7 ### Steps to Reproduce #### Objects created {#objects-created} - Create a Virtualization Cluster Type ```json { "id": 16, "url": "https://mynetbox.mydomain/api/virtualization/cluster-types/16/", "display": "TestType0", "name": "TestType0", "slug": "testtype0", "description": "", "custom_fields": {}, "cluster_count": 0 } ``` - Create a Virtualization Testcluster ```json { "id": 56, "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/", "display": "TestCluster0", "name": "TestCluster0", "type": { "id": 16, "url": "https://mynetbox.mydomain/api/virtualization/cluster-types/16/", "display": "TestType0", "name": "TestType0", "slug": "testtype0" }, "group": null, "tenant": null, "site": null, "comments": "", "tags": [], "custom_fields": { "Monitoring": "Auto", "mlagLacpMac": "" }, "device_count": 0, "virtualmachine_count": 0 } ``` - Create VM0 ```json { "id": 5210, "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5210/", "display": "TESTVM0", "name": "TestVM0", "status": { "value": "active", "label": "Active" }, "site": null, "cluster": { "id": 56, "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/", "display": "TestCluster0", "name": "TestCluster0" }, "role": null, "tenant": null, "platform": null, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "vcpus": null, "memory": null, "disk": null, "comments": "", "local_context_data": null, "tags": [], "custom_fields": {}, "config_context": null, } ``` - Create VM1 ```json { "id": 5211, "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5211/", "display": "TESTVM1", "name": "TESTVM1", "status": { "value": "active", "label": "Active" }, "site": null, "cluster": { "id": 56, "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/", "display": "TestCluster0", "name": "TestCluster0" }, "role": null, "tenant": null, "platform": null, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "vcpus": null, "memory": null, "disk": null, "comments": "", "local_context_data": null, "tags": [], "custom_fields": {}, "config_context": null, } ``` - Create TestTag ```json { "id": 26, "url": "https://mynetbox.mydomain/api/extras/tags/26/", "display": "TESTTag0", "name": "TESTTag0", "slug": "testtag0", "color": "9e9e9e", "description": "", "tagged_items": 0 } ``` - Create CustomField - Type: Multiple selection - Name: TestCF - Weight: 100 - Label: - Description - Required: False - Default: null - Filter logic: Loose - Content types: - Virtualization > virtual machine - Minimum value: - Maximum value: - Validation regex: - Choices: choice1,choice2,choice3,choiceN - Update VM0 with new custom_field ```json { "id": 5210, "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5210/", "display": "TESTVM0", "name": "TestVM0", "status": { "value": "active", "label": "Active" }, "site": null, "cluster": { "id": 56, "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/", "display": "TestCluster0", "name": "TestCluster0" }, "role": null, "tenant": null, "platform": null, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "vcpus": null, "memory": null, "disk": null, "comments": "", "local_context_data": null, "tags": [], "custom_fields": { "TestCF": [ "choice1", "choice2" ] }, "config_context": null, } ``` - Update VM1 with new custom_fields ```json { "id": 5211, "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5211/", "display": "TESTVM1", "name": "TESTVM1", "status": { "value": "active", "label": "Active" }, "site": null, "cluster": { "id": 56, "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/", "display": "TestCluster0", "name": "TestCluster0" }, "role": null, "tenant": null, "platform": null, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "vcpus": null, "memory": null, "disk": null, "comments": "", "local_context_data": null, "tags": [], "custom_fields": { "TestCF": [ "choice1", "choice2" ] }, "config_context": null, } ``` #### Steps {#steps} - Go to `virtualization/virtual-machines` - Search for VMS: TESTVM - Press "Refine Search" - Check the two VMs TESTVM0 and TESTVM1 - Press "Edit Selected" - Select the field of "Add tags" - Search and Enter "TESTTag0" - Press "Apply" ### Expected Behavior The Tag will be added to the selected vms, but the custom_field "TestCF will be untouched. ### Observed Behavior The custom_field "TestCF" is an empty list. VMS Aftert this action: - VM0 ```json { "id": 5210, "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5210/", "display": "TESTVM0", "name": "TestVM0", "status": { "value": "active", "label": "Active" }, "site": null, "cluster": { "id": 56, "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/", "display": "TestCluster0", "name": "TestCluster0" }, "role": null, "tenant": null, "platform": null, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "vcpus": null, "memory": null, "disk": null, "comments": "", "local_context_data": null, "tags": [ { "id": 26, "url": "https://mynetbox.mydomain/api/extras/tags/26/", "display": "TESTTag0", "name": "TESTTag0", "slug": "testtag0", "color": "9e9e9e" } ], "custom_fields": { "TestCF": [] }, "config_context": null, } ``` - VM1 ```json #+begin_src json { "id": 5211, "url": "https://mynetbox.mydomain/api/virtualization/virtual-machines/5211/", "display": "TESTVM1", "name": "TESTVM1", "status": { "value": "active", "label": "Active" }, "site": null, "cluster": { "id": 56, "url": "https://mynetbox.mydomain/api/virtualization/clusters/56/", "display": "TestCluster0", "name": "TestCluster0" }, "role": null, "tenant": null, "platform": null, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "vcpus": null, "memory": null, "disk": null, "comments": "", "local_context_data": null, "tags": [ { "id": 26, "url": "https://mynetbox.mydomain/api/extras/tags/26/", "display": "TESTTag0", "name": "TESTTag0", "slug": "testtag0", "color": "9e9e9e" } ], "custom_fields": { "TestCF": [] }, "config_context": null, } ```
adam added the type: bug label 2025-12-29 19:31:37 +01:00
adam closed this issue 2025-12-29 19:31:37 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 22, 2021):

Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

@jeremystretch commented on GitHub (Nov 22, 2021): Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.
Author
Owner

@alinmear commented on GitHub (Nov 25, 2021):

Thanks for your reply. I addressed your points and altered the description.

@alinmear commented on GitHub (Nov 25, 2021): Thanks for your reply. I addressed your points and altered the description.
Author
Owner

@jeremystretch commented on GitHub (Dec 3, 2021):

I'm not able to reproduce this behavior. I do note that in your example, you've tried posting custom field data prior to creating the custom field, in which case you should expect the custom field data for the object to be empty. This is unrelated to the bulk edit function.

@jeremystretch commented on GitHub (Dec 3, 2021): I'm not able to reproduce this behavior. I do note that in your example, you've tried posting custom field data prior to creating the custom field, in which case you should expect the custom field data for the object to be empty. This is unrelated to the bulk edit function.
Author
Owner

@alinmear commented on GitHub (Dec 6, 2021):

Thanks for your investigation. I am sry, for the unprecise writing above. Surely i added the custom field values after creating the custom_fields (i updated the description once again and sorry for the inconvinience).

We just updated our Teststage to the latest 3.x and this behaviour couldn't be reproduced with that version. So i think we can close this Issue as the problem seems to be fixed already.

@alinmear commented on GitHub (Dec 6, 2021): Thanks for your investigation. I am sry, for the unprecise writing above. Surely i added the custom field values after creating the custom_fields (i updated the description once again and sorry for the inconvinience). We just updated our Teststage to the latest 3.x and this behaviour couldn't be reproduced with that version. So i think we can close this Issue as the problem seems to be fixed already.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5703