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.