Pasting image in Confluence Questions crashes interface
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
Adding an answer into the Confluence Questions interface that adds an existing image from within the Confluence instance, then the Answer will appear to be accepted, but in reality, the answer will not appear at all. Adding two or more images that exist within Confluence will cause the user interface to throw a visible system ERROR in the interface as shown below:
The following appears in the atlassian-confluence.log
2017-04-17 21:35:35,140 ERROR [http-nio-8090-exec-11] [sf.hibernate.util.JDBCExceptionReporter] logExceptions Cannot delete or update a parent row: a foreign key constraint fails (`confluence_db`.`IMAGEDETAILS`, CONSTRAINT `FKA768048734A4917E` FOREIGN KEY (`ATTACHMENTID`) REFERENCES `CONTENT` (`CONTENTID`))
-- url: /wiki/cf/cq/answerquestion.action | traceId: d21bd7426290160e | userName: userName | referer: https://somesite.com/wiki/cf/questions/181422554/how-do-i-watch-a-question | action: answerquestion
2017-04-17 21:35:35,141 ERROR [http-nio-8090-exec-11] [sf.hibernate.impl.SessionImpl] execute Could not synchronize database state with session
-- url: /wiki/cf/cq/answerquestion.action | traceId: d21bd7426290160e | userName: userName | referer: https://somesite.com/wiki/cf/questions/181422554/how-do-i-watch-a-question | action: answerquestion
It is important to understand that this does not occur when uploading an image, or adding an image through drag and drop in the question interface. In addition you can still upload or drag and drop images into the Answers interface. It is only when you copy an existing image from within Confluence that this issue occurs.
Diagnosis
Review the atlassian-confluence.log for ERROR messages above, as they are key to understanding the issue. The ERROR being thrown shows that the interface is attempting to update the existing row for the attachment with itself. The message
Cannot delete or update a parent row: a foreign key constraint fails
means that the attachment is attempting to update itself with itself and this referential integrity fails.
Cause
The cause is that you cannot copy an object and update that object with itself in the database.
Workaround
You must follow these steps in order, or the workaround will not work. There is a very specific way to accomplish this, and you will need to follow these steps exactly to have the images appear correctly.
- Copy the text you wish to add to the Answer section in the format desired
- Add *space* for the images you wish to copy in the text
- Right-click on the images you wish to copy
- Choose Copy Image Location
Add the image link to the page where you wish the image to be placed as the actual link for example:
http://localhost:8090/510/download/attachments/65589/cake.jpg?version=1&modificationDate=1489665330655&api=v2
- Just before the start of the link to the image, add an exclamation mark '!' character
- Just after the end of the link to the image, add an exclamation mark '!' character
- Your image show now appear in the Answer
- Repeat this process for every image in the right place as you wish to add the image.
Resolution
There is no resolution at present for this issue. There is an open bug for this at CONFSERVER-47189 - Cannot save/edit question with image attachment.