System error displays in the UI when viewing Space attachments

Still need help?

The Atlassian Community is here for you.

Ask the community

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

Problem

When navigating to Space Tools > Content Tools > Attachments (listattachmentsforspace.action), the list of attachments fails to load and a system error is thrown in the UI. 

The following appears in the atlassian-confluence.log and in the UI. 

org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getDownloadPathWithoutVersion' in class
com.atlassian.confluence.pages.Attachment threw exception java.lang.NullPointerException at /pages/listattachmentsforspace.vm[line 56,
column 246]
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:223)
caused by: java.lang.NullPointerException
at com.atlassian.confluence.util.ConfluenceRenderUtils.getAttachmentsPathForContent(ConfluenceRenderUtils.java:88) 		

Diagnosis

Diagnostic Steps

  • Run the following SQL query to locate any attachments with a NULL PageID: 

    select * from content where contenttype = 'ATTACHMENT' and spaceid = (select spaceid from spaces where spacekey = 'spacekey-from-affected-space');

    Note the contentid for any attachments that have a NULL value in the pageid column. 

Cause

This error occurs when there is an attachment with a NULL pageid in the database.

Workaround

  1. Stop Confluence. 

  2. Run the following SQL to assign a valid pageid to any attachments that have a NULL value in the pageid column. 

    update content SET pageid = 'valid-pageid' where contentID = 'contentid-from-diagnostic';

    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.

  3. Start Confluence. 
  4. Once you've assigned a valid page, navigate to the page and move/delete the attachment as desired. 

Last modified on Nov 12, 2018

Was this helpful?

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