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

Copying a page with attachments and content properties with Copy Single Page API second time fails with error 500

    XMLWordPrintable

Details

    Description

      Issue Summary

      There is some conflict when copying a page with both attachment and content properties which are already exist in the destination page when "existing_page" destination type is used.

      Steps to Reproduce

      I was able to reproduce it on the production instance with "Comala Document Control for Confluence Cloud" app installed (adds content properties to the page).

      1. Install "Comala Document Control for Confluence Cloud" to your instance.
      2. Create a new page in any space.
      3. Attach a file to this page.
      4. From page's meatballs menu select "Add Page Workflow" with default options.
      5. Copy this page to another parent page using the Copy Page API with "copyProperties" and "copyAttachments" flags:
        POST <baseurl>/wiki/rest/api/content/<source_page_id>/copy
        {
            "destination": {
                "type": "parent_page",
                "value": "<parent_id>"
            },
            "copyAttachments": true,
            "copyProperties": true
        }
        

        It should be successfully copied and create new page with <new_page_id>.

      1. Copy the source page again, but now with "existing_page" destination type to <new_page_id> with "copyContentProperties" and "copyAttachments" flags:
        POST <baseurl>/wiki/rest/api/content/<source_page_id>/copy
        {
            "destination": {
                "type": "existing_page",
                "value": "<new_page_id>"
            },
            "copyAttachments": true,
            "copyProperties": true
        }
        

      Expected Results

      Page is copied successfully.

      Actual Results

      Three possible scenarios:

      A. Attachment's size is small (tested with 1KB):

      Request completes successfully.

      B. Attachment's size is medium (tested with 700KB image):

      Request fails with the following response:

      {
          "statusCode": 500,
          "message": "com.atlassian.confluence.core.persistence.confluence.StaleObjectStateException: javax.persistence.OptimisticLockException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1"
      }
      

      C. Attachment's size is big (tested with 1.6Mb file):

      Request fails with the following response: 

      {
          "statusCode": 409,
          "data": {
              "authorized": false,
              "valid": true,
              "errors": [],
              "successful": false
          },
          "message": "com.atlassian.confluence.api.service.exceptions.ConflictException: You're trying to edit an outdated version of that ContentProperty. Latest version is 11"
      }
      

       
      Removing attachment helps to resolve the issue as well as removing the "copyProperties" flag.

      Exception stack trace is attached.

      Workaround

      Currently there is no known workaround for this behavior. A workaround will be added here when available

      Attachments

        Issue Links

          Activity

            People

              rtoropov@atlassian.com Roman Toropov
              rtoropov@atlassian.com Roman Toropov
              Votes:
              15 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: