Copying a Space fails due to ConflictException related with a null JsonContentProperty
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
When a space administrator copies a space, it fails asking you to retry the copying process without further error details.
Environment
Confluence 8.5.X. an later
Diagnosis
In the atlassian-confluence.log
files, the following error can be found when searching for the related Copy space long running task entries:
2024-04-01 07:13:11,929 ERROR [Long running task: Copy space long running task] [dao.bulk.copy.DefaultBulkPageCopy] safeAction An exception occurred while trying to do a bulk page copy operation
-- url: /confluence/rest/copy/1.0/copy | userName: admin | referer: https://CONFLUENCE_URL/confluence/spaces/copyspaceoptions.action?key=ABCDEF | traceId: 334199d4dd67b04f
com.atlassian.confluence.api.service.exceptions.ConflictException: Cannot create new content property: JsonContentProperty{id='null', key='contentpropertyname-1', content=CollapsedReference{idProperties={id=ContentId{id=1037697302}, status=current, version=CollapsedReference{idProperties={number=1}, referentClass=class com.atlassian.confluence.api.model.content.Version}}, referentClass=class com.atlassian.confluence.api.model.content.Content}, version=null}: [SimpleMessage{key='jsonproperty.duplicate.key', args=[], translation='null'}]
at com.atlassian.confluence.api.model.validation.SimpleValidationResult.convertToServiceException(SimpleValidationResult.java:84)
at com.atlassian.confluence.api.model.validation.ValidationResult.throwIfNotSuccessful(ValidationResult.java:197)
at com.atlassian.confluence.plugins.contentproperty.ContentPropertyServiceImpl.create(ContentPropertyServiceImpl.java:63)
at com.atlassian.confluence.plugins.contentproperty.ContentPropertyServiceImpl.copyAllJsonContentProperties(ContentPropertyServiceImpl.java:105)
at jdk.internal.reflect.GeneratedMethodAccessor3976.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
...
...
Cause
In the table CONTENTPROPERTIES, this specific page that trigger the error has two different rows with the same version value for the "contentpropertyname-1" key. Hence, when the page is copied, the 'jsonproperty.duplicate.key' is triggered as one single page should not have a duplicate version of the same contentproperty
Solution
In order to address this issue, please follow the steps outlined here:
Run the following SQL statement to identify all the pages that contain a duplicate contentproperty entry:
SELECT c.pageid FROM content AS c JOIN bodycontent AS b ON c.contentid = b.contentid WHERE c.contenttype = 'CUSTOM' AND c.title = '<CONTENTPROPERTYNAME_1>' GROUP BY c.pageid,c.version HAVING COUNT(*) > 1
Replace the value of
<CONTENTPROPERTYNAME_1>
with the content property name indicated in the error found earlierOnce you have identified the pages with duplicated entries, execute the following
curl
command to delete the content property of that specific PAGEID:curl -i -u admin:admin -X DELETE "http://CONFLUENCE_HOST/confluence/rest/api/content/PAGE_ID/property/contentpropertyname-1"
Replace the variables
CONFLUENCE_HOST
andPAGE_ID
with the correspondent values.
You may find several pages affected by this same situation, if that's the case, removed those related to the specific space you are copying.- When the entries are remove, retry the copy of your space.