Error trying to update asset when display name is marked as unique and an asset with the same name exists in the trash

Hi,

If you make the “Display Name” default field unique as shown in the following screenshot:

and if you try to make a call to update an asset (e.g. PUT https://[instance]/api/v2/assets/8615/) with a payload like:

{
    "description": "abcd",
    "end_of_life": null,
    "type_fields": {
        "provider_type_16000480427": "VMWARE VCENTER",
        "item_id_16000797861": " ",
        "memory_size_16000797861": 0,
        "datastore_16000797862": " ",
        "cpu_core_count_16000797861": 0,
        "cpu_speed_16000797862": 0,
        "cluster_16000797862": " ",
        "instance_uuid_16000797862": " ",
        "hardware_vendor_16000797862": " ",
        "datacenter_16000797862": " ",
        "cd_serial_number_16000797862": " ",
        "ip_address_16000797861": " ",
        "os_type_16000797862": "ESXi",
        "total_disk_size_16000797861": 0,
        "cloud_cost_16000480427": 0,
        "item_name_16000797861": " ",
        "hypervisor_16000797862": "ESXi  ",
        "state_16000797861": "Unknown"
    },
    "asset_type_id": 16000797862,
    "name": "Test VCenter Host"
}

the API call will fail with a 400 error:

{
    "description": "Validation failed",
    "errors": [
        {
            "field": "base",
            "message": "Display Name must be unique",
            "code": "invalid_value"
        }
    ]
}

if an asset with the same name as the one you are trying update exists in the trash.

If an asset with the same name did not exist in the trash, then the update of the asset is successful (200 status code). Here is the successful response:

{
    "description": "abcd",
    "end_of_life": null,
    "type_fields": {
        "provider_type_16000480427": "VMWARE VCENTER",
        "item_id_16000797861": " ",
        "memory_size_16000797861": 0,
        "datastore_16000797862": " ",
        "cpu_core_count_16000797861": 0,
        "cpu_speed_16000797862": 0,
        "cluster_16000797862": " ",
        "instance_uuid_16000797862": " ",
        "hardware_vendor_16000797862": " ",
        "datacenter_16000797862": " ",
        "cd_serial_number_16000797862": " ",
        "ip_address_16000797861": " ",
        "os_type_16000797862": "ESXi",
        "total_disk_size_16000797861": 0,
        "cloud_cost_16000480427": 0,
        "item_name_16000797861": " ",
        "hypervisor_16000797862": "ESXi  ",
        "state_16000797861": "Unknown"
    },
    "asset_type_id": 16000797862,
    "name": "Test VCenter Host"
}

Note also that even if I try to add or update an asset which has the same name as one in the trash and if Display Name field is marked as unique, the UI shows the error “Display Name must be unique”.

Should I be able to add or update an asset even if one with the same name exists in the trash if the Display Name field is marked as unique?

Thanks,

Chris

Hi @Chris_Scaglione,

Likely this would be expected behavior. Trash is just a filtered view of all of the Asset objects. The unique value is enforcing it across all existing objects in Assets. Even the standard view is a Filtered view where Trash=False vs the trash view being Trash=True, however, the objects are all in the same ‘table’ and would trigger an exception as that object with that name exists.

1 Like

Hi @rasimm ,

Thanks for confirming that this would be expected behavior.

Thanks,

Chris

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.