Details
-
Bug
-
Resolution: Unresolved
-
Medium
-
Minor
-
Description
Issue Summary
The POST Restore Content Version API endpoint (/wiki/rest/api/content/{id}/version) fails to restore a previous version of an attachment.
This endpoint is designed to revert an attachment to a specified previous version, subsequently setting it as the current version.
However, a critical issue arises when, after utilising this feature to revert an attachment, any attempt to delete an older version of that same attachment inadvertently leads to the deletion of the current version as well, rendering the attachment completely inaccessible and resulting in data loss.
Steps to Reproduce
- Create a new page and add the attachment macro.
- Create a text file named file.txt on your computer, inputting "INITIAL VERSION" as its content.
- Upload file.txt to the Confluence page using the Attachments page's upload feature.
- Edit file.txt on your computer to change its contents to "SECOND VERSION".
- Upload the modified file.txt to the same Confluence page, creating version 2 (v.2) of the attachment.
- To revert the attachment back to Version 1, utilize the Restore Content Version API as shown:
curl --location 'https://yoursite.atlassian.net/wiki/rest/api/content/{attachment-id}/version' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic xxx' \ --data '{ "operationKey": "restore", "params": { "versionNumber": 1, "message": "Reverted to V.1", "restoreTitle": true } }'
You'll receive a 200 OK response, suggesting the operation was successful. However, when you check the attachment versions, things don't line up as expected.
Expected Results
When you make that POST request, the latest version of the file should be the same version you've indicated on your request and not the previous one.
Deleting the previous version, should also not result to deleting of the current / latest version.
Actual Results
First issue: Despite the API's response, viewing the attachment or its new version 3 still shows the "SECOND VERSION" content. This indicates the revert operation didn’t change the attachment back to its original content as intended.
Second issue: If you delete what appears to be just version 2, aiming to tidy up, both versions 2 and 3 become inaccessible. Trying to view the attachment or its reverted version results in an error, indicating the resources can't be found. Showing the following error
{"error":{"code":"NotFoundError","title":"Some resources were not found","href":"https://api.media.atlassian.com#NotFoundError"}}
Workaround
Currently there is no known workaround for this behavior. A workaround will be added here when available
Attachments
Issue Links
- mentioned in
-
Page Loading...