ValidationInsightException when updating Assets attributes

Hi,
need help troubleshooting exception in Assets ObjectFacade when trying to update attributes in scriptrunner.

ValidationInsightException: Validation errors were found: rlabs-insight-attribute-297: ErrorMessage{i18nKey='rlabs.insight.i18n.constraint.violation.unique

The error started to appear after Jira upgrade(8 → 9), before scripts were executing correctly. The exception is raised when I try to edit asset attributes.

void storeObjectAttributeBean(ObjectBean objectBean, Integer attributeId, String... values) {
    ObjectTypeAttributeBean objectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttribute(attributeId).createMutable()
    ObjectAttributeBean objectAttributeBean = objectFacade.loadObjectAttributeBean(objectBean.getId(), objectTypeAttributeBean.getId())
    ObjectAttributeBean newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(objectBean, objectTypeAttributeBean, values)
    if (objectAttributeBean != null) {
        newObjectAttributeBean.setId(objectAttributeBean.getId())
    }
    objectFacade.storeObjectAttributeBean(newObjectAttributeBean)
}

void deleteObjectAttributeBean(ObjectBean objectBean, Integer attributeId) {
        ObjectAttributeBean objectAttributeBean = objectFacade.loadObjectAttributeBean(objectBean.getId(), attributeId)
        if (objectAttributeBean) {
            objectFacade.deleteObjectAttributeBean(objectAttributeBean.getId())
        }
    }

The exception is raised when methods are invoked multiple times in a short time.

deleteObjectAttributeBean(asset, attributeId);
storeObjectAttributeBean(asset, attributeId);
deleteObjectAttributeBean(asset, attributeId);
storeObjectAttributeBean(asset, attributeId);

But if I insert Thread.sleep(1000) between each invocation, then no exceptions are raised.

1 Like

@Raman_Paulau Did you find any answers for this why it throws a validation error?
I am facing a same problem after moving from JSM 8 to 9? Any API changes that you know of?

Hi, I’m still unsure of what is causing this exception. At the moment, I am using a workaround. I have wrapper functions that interact with the Asset’s attributes, so it was simple for me to extend them to catch and ignore this exception.

Okay. In my case I do not want to ignore the exception as the updating the attribute successfully is quite important as the lot of the logic of the system we built is dependant on that.
This looks like a bug in the APi to me. I would like to know if there is any alternative way of updating the object.
Have you contacted Atlassian about this? I have created a ticket myself, awaiting the reply from Atlassian.

Hi @Raman_Paulau,

Sorry to hear that you have encountered this issue.

If you enable debug logging on the package com.riadalabs.jira.plugins.insight.services.validation and you are seeing the debug log “Unique check: Concurrent modification occurred on attribute”, this is a bug related to the following bug ticket - we have a fix ready for this which will be released in a future version - if you watch the bug you’ll be able to follow which version of JSM it lands in: [JSDSERVER-12676] ValidationInsightException when updating object attributes with unique values - Create and track feature requests for Atlassian products..

If this is the error that you see (which I think it will be as I was also able to replicate this), it is occurring because Assets is wrongly detecting that the unique attribute on the object is changing and applying a conservative concurrent check to help in clustered mode.

There is a feature flag which you can disable to revert the behaviour, but it will rollback significant memory optimisations that were made (Jira Service Management 5.0.x release notes | Atlassian Support | Atlassian Documentation), so if you already have a workaround, I would recommend following that, rather than disabling the feature.

If you did want to disable the feature, you can do so by adding insight.index.memory.improvement.disabled in the dark features followed by an Asset re-index.

Please watch the bug ticket in the meantime and you’ll get a notification with the fix version soon.

Sorry again about the inconvenience here.

Thanks,
Craig.
JSM DC

Hi @CraigShannon,

Thank you for your message and for explaining the issue. For the time being, I will continue to use my workaround until the fix is available. I will also keep an eye on the bug ticket to receive updates on the release of the fix.

Thank you for your assistance and for keeping me informed.

1 Like