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

      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

          Form Name

            [JSDSERVER-14880] Updating a unique assets attribute value results in ValidationInsightException

            Bartosz Ornatowski made changes -
            Resolution New: Fixed [ 1 ]
            Status Original: Waiting for Release [ 12075 ] New: Closed [ 6 ]
            Bartosz Ornatowski made changes -
            Fix Version/s Original: 15.15.0 [ 107097 ]
            Fix Version/s New: 5.15.0 [ 107090 ]
            SET Analytics Bot made changes -
            Support reference count Original: 2 New: 3
            SET Analytics Bot made changes -
            UIS Original: 40 New: 17
            Yufei Zuo made changes -
            Status Original: In Progress [ 3 ] New: Waiting for Release [ 12075 ]
            Yufei Zuo made changes -
            Fix Version/s New: 15.15.0 [ 107097 ]
            Yufei Zuo made changes -
            Status Original: Short Term Backlog [ 12074 ] New: In Progress [ 3 ]
            Yufei Zuo made changes -
            Remote Link New: This issue links to "Service Desk Master › JSM/DC - Snyk reports diff › stable-issue-15.15-JSDSERVER-14880-remove-500-ms (server-syd-bamboo)" [ 865332 ]
            Yufei Zuo made changes -
            Remote Link New: This issue links to "Service Desk - Stable 5.15.x › Service Desk Find fix versions - Stable - 5.15.x › stable-issue-15.15-JSDSERVER-14880-remove-500-ms (server-syd-bamboo)" [ 865277 ]
            Yufei Zuo made changes -
            Remote Link New: This issue links to "Service Desk - Stable 5.15.x › OBR generation for JSM (Service Desk - Stable 5.15.x) › stable-issue-15.15-JSDSERVER-14880-remove-500-ms (server-syd-bamboo)" [ 865418 ]

              3d5a17e800ca Yufei Zuo
              399904f8a539 Tripta Kaur
              Affected customers:
              1 This affects my team
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: