Some object's attachment not accessible due to NullPointerException: mimeType


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

When browsing an object with existing attachment(s), the attachments do not appear in the attachments panel. There are error message and sign on the screen indicating there's issue with the object's attachments

Environment

Any Insight version

Diagnosis

  • From the UI, you could see errors like "Something went wrong. Contact administrator" or "Failed to retrieve the attachments". In the Attachments panel, it would be blank or with a message "Can't find attachments..."
  • Error below can be seen in the application-jira.log

    2022-04-25 14:03:27,355+0200 http-nio-8080-exec-2 ERROR admin 843x5747x1 144kvqe 192.168.56.23,10.10.2.53 /rest/insight-am/1/assets/ASSETITSM-40/attachments [i.r.core.rest.ExceptionErrorMapper] Oops
    com.riadalabs.jira.plugins.insight.common.exception.RuntimeInsightException: InsightRuntimeException: java.lang.NullPointerException: mimeType; nested exception is: mimeType
    java.lang.NullPointerException: mimeType
    	at java.base/java.util.Objects.requireNonNull(Objects.java:246)
    	at com.riadalabs.jira.plugins.insight.services.model.ImmutableAttachmentBean$Builder.setMimeType(ImmutableAttachmentBean.java:547)
    	at com.riadalabs.jira.plugins.insight.services.core.dal.transformation.ActiveObjectsAssemblerImpl.assembleAttachment(ActiveObjectsAssemblerImpl.java:545)
    	at com.riadalabs.jira.plugins.insight.services.core.dal.transformation.ActiveObjectsAssemblerImpl.assembleAttachments(ActiveObjectsAssemblerImpl.java:556)
    	at com.riadalabs.jira.plugins.insight.services.core.dal.impl.ObjectDalImpl.findAttachments(ObjectDalImpl.java:527)
    	at com.riadalabs.jira.plugins.insight.services.core.ObjectServiceImpl.findAttachments(ObjectServiceImpl.java:1796)
    	at io.riada.core.insight.service.ObjectServiceImpl.findObjectAttachments(ObjectServiceImpl.kt:136)
    	at io.riada.assetmgt.asset.service.AttachmentServiceImpl.findAllByAssetKey(AttachmentServiceImpl.kt:56)
    	at io.riada.assetmgt.asset.rest.AssetAttachmentResource.findAllByAssetKey(AssetAttachmentResource.kt:68)
    ...
  • The SQL below returns at least one row in the result

    SELECT * FROM "AO_8542F1_IFJ_OBJ_ATTACH" WHERE "MIME_TYPE" IS null;

Cause

At least one of the object attachments do not have a MIME type. If the object has multiple attachments but at least one without MIME type, the error will occur and none of the attachments will be accessible

Solution

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

Remove all attachments without MIME type from the database using the SQL query below.

delete from "AO_8542F1_IFJ_OBJ_ATTACH" WHERE "MIME_TYPE" IS null;



Last modified on Aug 11, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.