How-to fix /auditing/view returns 500 Error Page

After installing and using Metadata for Jira in versions 4.5.0 to 4.5.1 it may happen that Audit Log page displays the following error page. 

The following lines exist in the server logs.

20xx-xx-xx 14:55:03,056 http-nio-8080-exec-3 ERROR admin 895x171056x1 16uf4he 12.92.127.88,127.0.0.1 /auditing/view [o.a.c.c.C.[.[localhost].[/i/j].[action]] Servlet.service() for servlet [action] threw exception
java.lang.NumberFormatException: For input string: "META"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Long.parseLong(Long.java:589)
        at java.lang.Long.parseLong(Long.java:631)
        at com.atlassian.jira.plugins.auditing.rest.responses.AssociatedItemResponse.getAssociatedItemDetails(AssociatedItemResponse.java:88)
        at com.atlassian.jira.plugins.auditing.rest.responses.AssociatedItemResponse.fromAssociatedItem(AssociatedItemResponse.java:77)
        at com.atlassian.jira.plugins.auditing.rest.responses.RecordTransformer.fromAuditRecord(RecordTransformer.java:45)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)

This error occurs if the audit logs contain one or more of our entries that could be processed by Jira up to version 8.0. The processing of the entries has changed to version 8.0 of Jira and now this error occurs.

Access to the audit logs is still possible using Rest (see also: https://docs.atlassian.com/software/jira/docs/api/REST/8.3.3/#api/2/auditing-getRecords).

Instructions

To fix the problem, you must perform the following steps:

  1. Log in as administrator
  2. Install Metadata for Jira >= 4.5.2
  3. Call the following URL 
    http://YOUR_JIRA_SERVER/rest/metadata/1.0/admin/cleanupProjectAuditLog
  4. The following lines can now be found in the server logs.

    20... WARN ... /rest/metadata/1.0/admin/cleanupProjectAuditLog [s.e.j.metadata.rest.AdminRestService] cleanup request - received
    20... WARN ... /rest/metadata/1.0/admin/cleanupProjectAuditLog [s.e.j.metadata.rest.AdminRestService] cleanup request - checking audit log entries with id > 0
    20... WARN ... /rest/metadata/1.0/admin/cleanupProjectAuditLog [s.e.j.metadata.rest.AdminRestService] defect audit log entry detected - deleting :
    {summary=Metadata has been updated : In T... ... d=11295, deltaFrom=}
    ...
    20... WARN ... /rest/metadata/1.0/admin/cleanupProjectAuditLog [s.e.j.metadata.rest.AdminRestService] cleanup request - checking audit log entries with id > 10923
    20... WARN ... /rest/metadata/1.0/admin/cleanupProjectAuditLog [s.e.j.metadata.rest.AdminRestService] cleanup request - done
  5. After that, you can use the audit log again