Details
-
Bug
-
Resolution: Fixed
-
Medium
-
5.7, 5.8.5, 5.8.18, 5.9.4, 1000.119.0
-
36
-
Severity 2 - Major
-
Description
NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.
Summary
In-line Comments and Resolved Comments are imported with a Space Export, but throw a 500 error when the REST call is made for rendering the Page. This has been replicated with space exports from Confluence Cloud and Confluence Server.
Environment
- Confluence Cloud
- Confluence Server 5.7, 5.8.18 or 5.9.4.
- The Space has Resolved in-line comments
Steps to Reproduce
- Go to a Space and a Page within that Space. Add two in-line comments and resolve one of them.
- Do a full XML export of the Space
- Import the Space export into a new instance (either same version or same major version)
- Notice the import completes successfully, but the in-line and resolved comments are not displayed even though they are present in the entities.xml file and database.
Expected Results
In-line comments are displayed.
Actual Results
The in-line comments are imported into the database, however the user_key is not mapped correctly from the old instance to the new instance.
Workaround
SQL manipulation in the database is not supported. Please make sure you have a database backup.
- Shutdown Confluence
- Run this query
select stringval from contentproperties where propertyname = 'status-lastmodifier' and stringval not in (select user_key from user_mapping) group by stringval;
- In next step after this, you will need to run update statements to replace the username and old_user_key values. To obtain the corresponding username values, you can use the SQL below on your source Confluence database. If the source was a Cloud instance, you can ask Atlassian Support to run this query for you on your Confluence Cloud database, using the list of values from the previous step.
select distinct cp.stringval, um.username, um.lower_username from contentproperties cp join user_mapping um on cp.stringval = um.user_key where propertyname = 'status-lastmodifier' and stringval in ( 'ff80808157d6342b0157d8d795020000', 'ff80808158be2e8d0158c14ba8ec0001', 'ff80808159726edc015983f2cb090001' );
- Run this code to update the resolved comment's user to the correct user_key
update contentproperties set stringval = (select user_key from user_mapping where username = '<username>') where stringval = '<old user_key>';
Where
- <username> is the username of the User who originally resolved the in-line comment.
- <old user_key> is the value identified from the first SQL query.
- Restart Confluence
In-line comments should now display
Analysis
In-line comments are generated by a REST call
- http://confluence.mycompany.com/rest/inlinecomments/1.0/comments?containerId=<pageid>&_=1460592565065
And this returns a 500, which in the logs is
2016-04-14 10:44:11,224 ERROR [http-nio-8090-exec-8] [common.error.jersey.ThrowableExceptionMapper] toResponse Uncaught exception thrown by REST service: null -- url: /rest/inlinecomments/1.0/comments | userName: jrichards java.lang.NullPointerException at com.atlassian.confluence.plugins.inlinecomments.helper.InlineCommentUserHelper.getFullNameForUserKey(InlineCommentUserHelper.java:31) at com.atlassian.confluence.plugins.inlinecomments.entities.InlineCommentBuilder.buildResolveData(InlineCommentBuilder.java:54) at com.atlassian.confluence.plugins.inlinecomments.entities.InlineCommentBuilder.convertCommentToInlineComment(InlineCommentBuilder.java:111) at com.atlassian.confluence.plugins.inlinecomments.entities.InlineCommentBuilder.build(InlineCommentBuilder.java:84) at com.atlassian.confluence.plugins.inlinecomments.service.InlineCommentServiceImpl.getCommentThreads(InlineCommentServiceImpl.java:255) at com.atlassian.confluence.plugins.inlinecomments.resources.InlineCommentResource.getInlineComments(InlineCommentResource.java:82) at sun.reflect.GeneratedMethodAccessor1269.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497)
Here's the code
public String getFullNameForUserKey(String userKey) { if (StringUtils.isNotEmpty(userKey)) { return userAccessor.getUserByKey(new UserKey(userKey)).getFullName(); } return i18nBeanFactory.getI18NBean(getUserLocale()).getText(ANONYMOUS_KEY); }
In the Space export XML, the in-line comment is associated with the user_key but if the user is not in the new Confluence, or if they do exist but don't have that same user_key then there's no Full name.
- The above code needs to be more robust for checking nulls
- The import needs to map in-line comments to username the same way Page ownership and other items are mapped