Navigating to Trash within a Space throws a 'System Error' in Confluence Data Center.
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Navigating to the Trash tab within a Space throws a 'System Error' if the trash contains ATTACHMENTS with a null pageid.
Environment
- Confluence Data Center
- The issue occurs in Confluence versions 8.5.6 and later.
Note: This issue may also occur in earlier versions, though it has not been tested.
Diagnosis
All spaces have their own trash. To access it, you'll need Space Admin privileges.
- Click on the Space Tools option in the sidebar.
- Click on Content Tools.
- On the new page, click on the Trash tab.
- In the UI, the following error is observed:
The following error is observed in the atlassian-confluence.log file:
2024-07-24 15:20:32,127 ERROR [http-nio-8090-exec-1793] [atlassian.confluence.status.SystemErrorInformationLogger] logException Unhandled exception af89df5d-851f-4f43-aea9-01ea8e842168: Invocation of method 'getTrash' in class com.atlassian.confluence.pages.actions.ViewTrashAction threw exception java.lang.NullPointerException at /pages/viewtrash.vm[line 12, column 32] -- traceId: c1a13338ce7800e8 org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getTrash' in class com.atlassian.confluence.pages.actions.ViewTrashAction threw exception java.lang.NullPointerException at /pages/viewtrash.vm[line 12, column 32] <Trimmed> Caused by: java.lang.NullPointerException at java.base/java.util.Objects.requireNonNull(Objects.java:221) at com.atlassian.confluence.pages.Attachment.getUrlPath(Attachment.java:232) <Trimmed>
Cause
The error occurs due to a NullPointerException
caused by a null
value for the pageid
associated with a content type Attachment
. Specifically, this is evident in the stack trace at com.atlassian.confluence.pages.Attachment.getUrlPath(Attachment.java:232)
, where the method getUrlPath
attempts to retrieve the URL path for an attachment but encounters a null
value. This indicates that the Attachment
object is missing a valid pageid
, which is essential for constructing its URL path. Consequently, the system is unable to process the request, resulting in the observed exception when trying to view the trash in Confluence.
It is unclear why the pageid
had a null
value for the attachments in the trash.
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.
- Backup the database.
- Note the
spacekey
of the Space on which you are trying to access the trash.
2.1. Look at the URL in your browser’s address bar after navigating to Content Tools. Thespacekey
will be at the end of the URL, right after thekey=
parameter. - Shutdown Confluence.
Run the following SQL query to determine which
Attachment
contentids havenull
pageid:
SELECT * FROM content c JOIN spaces s ON c.spaceid = s.spaceid WHERE s.spacekey = '<Replace with Space key>' AND c.content_status = 'deleted' AND c.contenttype = 'ATTACHMENT' AND c.pageid IS NULL;
Update the records from the output of the above query to have a
pageid:
UPDATE content SET pageid = '<page_id>' WHERE contentid = '<Depending on the output of the above query>';
5.1. Since we are unable to determine the original page to which these attachments belonged, we can assign them to any existing
pageid
or to a previously removedpageid
.
5.2. Do this for each item in the output of the query on step 4.- Start Confluence.
- Navigating to the trash of this Space should be successful at this point.