Fetching page history through REST API throws a NullPointerException at HistoryBuilder.createdDate

Still need help?

The Atlassian Community is here for you.

Ask the community

This article only applies to Atlassian's server products. Learn more about the differences between cloud and server.

Problem

Fetching pages through the REST API and expanding its history (e.g. history.lastupdated) results in a 500 HTTP code and the following error on the atlassian-conlfuence.log file:

[rest.api.model.ExceptionConverter] convertServiceException No status code found for exception, converting to internal server error :
 -- url: /rest/api/content/<ID>/child/page | traceId: xxxxx | userName: admin
java.lang.NullPointerException
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210)
        at com.atlassian.confluence.api.model.content.History$HistoryBuilder.createdDate(History.java:231)


Diagnostic Steps


Run the following query on the database to check for NULL values:

SELECT * from content where creationdate is NULL and content_status = 'current' and (contenttype = 'PAGE' or contenttype = 'BLOGPOST' or contenttype = 'ATTACHMENT');

Cause

If the query above returns any results, this is the cause of the problem. It is expected that all published versions of a given content should have valid dates in this column. If not, the NPE is returned when fetching its history.

(warning) Notice that it is expected to have NULL values for that column if the content_status is DRAFT or DELETED. However, if the content_status is CURRENT, that should not happen.

Resolution

Run the following query to set valid dates for those entries:

UPDATE content SET creationdate ='2018-01-01 01:01:01.001', lastmoddate = '2018-01-01 01:01:01.001' where creationdate is NULL and content_status = 'current' and (contenttype = 'PAGE' or contenttype = 'BLOGPOST');

Ensure that you have stopped the application and taken a database backup before executing this query.

Note

It is not yet known why this situation may happen. On most of the case where this has been seen, the pages affected were created in an unusual way (not from the UI). Below are the most common causes:

  1. Pages/spaces imported from other wiki tools
  2. Pages created using scripts or plugins
  3. Any other type of content migration


DescriptionFetching page history through REST API throws a NullPointerException at HistoryBuilder.createdDate
ProductConfluence
Last modified on Oct 25, 2019

Was this helpful?

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