Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-78434

POST Restore content version (/wiki/rest/api/content/{id}/version) does not restore historical version of an attachment.

    XMLWordPrintable

Details

    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

      1. Create a new page and add the attachment macro.
      2. Create a text file named file.txt on your computer, inputting "INITIAL VERSION" as its content.
      3. Upload file.txt to the Confluence page using the Attachments page's upload feature.
      4. Edit file.txt on your computer to change its contents to "SECOND VERSION".
      5. Upload the modified file.txt to the same Confluence page, creating version 2 (v.2) of the attachment.
      6. 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

          Activity

            People

              Unassigned Unassigned
              26a024868f5f Sherica Ocbania
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: