Uploaded image for project: 'Jira Service Management Data Center'
  1. Jira Service Management Data Center
  2. JSDSERVER-14880

Updating a unique assets attribute value results in ValidationInsightException

    XMLWordPrintable

Details

    Description

      Issue Summary

      Updating an Assets object with unique attribute values multiple times in a short timespan will result in a ValidationInsightException with the message "The attribute '<Attribute Name>' has to be unique"

      This is reproducible on Data Center: yes

      Steps to Reproduce

      1. Create a new Assets schema as a 'Sample IT Asset Schema'. Just to get some object types in there automatically.
      2. In the newly created schema, go to the 'Host' object and edit the attributes.
      3. Add an attribute called 'Codename' with type 'Default', Type Value 'Text' and make it unique.
      4. Note down the attribute ID of this attribute.
      5. Go back to the object, and create a new Host object being sure to put a value in the 'Codename' attribute.
      6. Note down the ObjectID and ObjectTypeID from the URL.
      7. Run the following cURL command to edit the Object twice one after the other (Note you will need to fill in the following: username, password, baseURL, objectID, objectTypeID, attributeID):
        for i in {1..2}
        do
            curl -u <username>:<password> -X 'PUT' \
            '<baseURL>/rest/insight/1.0/object/<objectID>' \
            -H 'accept: application/json' \
            -H 'Content-Type: application/json' \
            -d '{
                "objectTypeId": <objectTypeID>,
                "attributes": [
                    {         
                        "objectTypeAttributeId": <attributeID>,
                        "objectAttributeValues": [
                            {
                                "value": "Longhorn"
                            }
                        ]
                    }
                ]
            }'
        done 

      Expected Results

      Attribute value is updated successfully both times.

      Actual Results

      The first update succeeds but the second fails with the error "The attribute 'Codename' has to be unique"

      The below exception is thrown in the xxxxxxx.log file:

      [INFO] [talledLocalContainer] 2023-11-23 16:38:36,470 http-nio-2990-exec-3 url: /jira/rest/insight/1.0/object/32; user: admin INFO admin 998x24618x1 1mq3e3l 127.0.0.1 /rest/insight/1.0/object/32 [c.r.j.p.i.services.util.ServiceUtil] InsightException:ValidationInsightException: Validation errors were found: rlabs-insight-attribute-811: ErrorMessage{i18nKey='rlabs.insight.i18n.constraint.violation.unique', parameters=[Codename], additionalMessage=null};
      [INFO] [talledLocalContainer] com.riadalabs.jira.plugins.insight.common.exception.ValidationInsightException: ValidationInsightException: Validation errors were found: rlabs-insight-attribute-811: ErrorMessage{i18nKey='rlabs.insight.i18n.constraint.violation.unique', parameters=[Codename], additionalMessage=null};
      [INFO] [talledLocalContainer]     at com.riadalabs.jira.plugins.insight.services.validation.ValidateObjectImpl.validateObjectBean(ValidateObjectImpl.java:229)
      [INFO] [talledLocalContainer]     at com.riadalabs.jira.plugins.insight.services.core.ObjectServiceImpl.storeObject(ObjectServiceImpl.java:409)
      [INFO] [talledLocalContainer]     at com.riadalabs.jira.plugins.insight.services.core.ObjectServiceImpl.storeObject(ObjectServiceImpl.java:283)
      [INFO] [talledLocalContainer]     at com.riadalabs.jira.plugins.insight.channel.web.api.rest.services.object.ObjectResource.updateObject(ObjectResource.java:391)
      [INFO] [talledLocalContainer]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [INFO] [talledLocalContainer]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      [INFO] [talledLocalContainer]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [INFO] [talledLocalContainer]     at java.base/java.lang.reflect.Method.invoke(Method.java:566) 

      Workaround

      Wait at least 500ms in between updates for unique attributes

      Attachments

        Issue Links

          Activity

            People

              3d5a17e800ca Yufei Zuo
              399904f8a539 Tripta Kaur
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:

                Backbone Issue Sync