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

Copying a page with Giphy attachment using Copy Single Page and Copy Page Hierarchy APIs fails due to an attachment size mismatch

    XMLWordPrintable

Details

    Description

      Issue Summary

      When using either Copy Single Page REST API or Copy Page Hierarchy REST API to copy a page with Giphy attachment (seems to be any) results to a 500 error.

      Steps to Reproduce

      1. Create a new page.
      2. Use "/" menu to insert a Giphy image to the page.
      3. Publish the page.
      4. Go to Attachments using a page meatballs menu. Note the attached gif size.
      5. Go back to the page, click on the embedded gif. Note the size of the gif file displayed in attachment view overlay.
      6. If sizes from steps 4 and 5 do NOT match, go to the step 7, otherwise remove the attachment and go to the step 2.
      7. Use Copy Single Page API or Copy Page Hierarchy REST API to copy the page. Make sure to set copyAttachments flag to true.
        // Copy single page
        POST {{baseUrl}}/rest/api/content/<page_id>/copy
        {
          "destination": {
            "type": "parent_page",
            "value": "<new_parent_page_id>"
          },
          "copyAttachments": true,
        }
        
        // Copy page hierarchy
        POST {{baseurl}}/rest/api/content/<page_id>/pagehierarchy/copy
        {
          "copyAttachments": true,
          "copyProperties": true,
          "copyLabels": true,
          "destinationPageId": "<new_parent_page_id>",
          "titleOptions": {
            "prefix": "[COPY] "
          }
        }
        

      Expected Results

      Page is copied to a new destination and Giphy image is visible on the page.

      Actual Results

      If page was copied with a Copy Single Page API then it'll fail with the following error:

      {
          "statusCode": 500,
          "message": "com.atlassian.confluence.pages.attachments.AttachmentDataStreamSizeMismatchException: Attachment data stream contains a different number of bytes to the declared size of the attachment. Expected: 1310158, actual: 9025927"
      }
      

      If page was copied with a Copy Page Hierarchy API then the scheduled long running task will be running long time, with elapsedTime reaching 75 000 and starting over from 0 several times, eventually reporting success. There seems to be two outcomes possible:

      1. Page hierarchy is copied multiple times (5) to the destination page. Embedded gif image says "Failed to load" in this case. Symptoms seems to be very similar to CONFCLOUD-67045.
      2. Copied page never appears at the destination.

      Logs report the same error as for Copy Single Page API:

      com.atlassian.confluence.pages.attachments.AttachmentDataStreamSizeMismatchException: Attachment data stream contains a different number of bytes to the declared size of the attachment. Expected: 251811, actual: 310223
      com.atlassian.confluence.pages.persistence.dao.filesystem.filestore.FileStoreAttachmentDataFileSystem.copyAttachmentData(FileStoreAttachmentDataFileSystem.java:116)
      com.atlassian.confluence.pages.persistence.dao.filesystem.TrackingAttachmentDataFileSystem.copyAttachmentData(TrackingAttachmentDataFileSystem.java:62)
      com.atlassian.confluence.pages.persistence.dao.filesystem.FileSystemAttachmentDataDao.copyAttachmentData(FileSystemAttachmentDataDao.java:129)
      com.atlassian.confluence.pages.persistence.dao.hibernate.AbstractHibernateAttachmentDao.copyAttachment(AbstractHibernateAttachmentDao.java:332)
      com.atlassian.confluence.pages.attachments.CachingAttachmentDao.copyAttachment(CachingAttachmentDao.java:208)
      com.atlassian.confluence.pages.DefaultAttachmentManager.copyAttachment(DefaultAttachmentManager.java:469)
      com.atlassian.confluence.pages.DefaultAttachmentManager.copyAttachments(DefaultAttachmentManager.java:453)
      com.atlassian.confluence.pages.DelegatorAttachmentManager.copyAttachments(DelegatorAttachmentManager.java:184)
      com.atlassian.confluence.pages.CachingAttachmentManager.copyAttachments(CachingAttachmentManager.java:145)
      sun.reflect.GeneratedMethodAccessor2184.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      java.lang.reflect.Method.invoke(Method.java:498)
      org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
      org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
      org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
      org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
      com.sun.proxy.$Proxy141.copyAttachments(Unknown Source)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService.lambda$copyOtherEntities$11(DefaultPageCopyService.java:492)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService.safeAction(DefaultPageCopyService.java:386)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService.copyOtherEntities(DefaultPageCopyService.java:489)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService.saveAsNewPage(DefaultPageCopyService.java:633)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService.copyPage(DefaultPageCopyService.java:458)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService.access$400(DefaultPageCopyService.java:91)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService$BulkPageCopyAction.process(DefaultPageCopyService.java:712)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService$BulkPageCopyAction.process(DefaultPageCopyService.java:686)
      com.atlassian.confluence.impl.hibernate.bulk.RecursiveHibernateBulkAction.executeInternal(RecursiveHibernateBulkAction.java:97)
      com.atlassian.confluence.impl.hibernate.bulk.RecursiveHibernateBulkAction.execute(RecursiveHibernateBulkAction.java:54)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService.deepCopyInternal(DefaultPageCopyService.java:257)
      com.atlassian.confluence.pages.persistence.dao.bulk.copy.DefaultPageCopyService.deepCopy(DefaultPageCopyService.java:184)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      java.lang.reflect.Method.invoke(Method.java:498)
      org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
      org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
      org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
      org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:16)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      cloud.atlassian.logmon.datadog.publisher.internal.DefaultFunctionalTimeRecorder.with(DefaultFunctionalTimeRecorder.java:24)
      com.atlassian.confluence.util.profiling.ConfluenceMonitoringMethodInterceptor.invoke(ConfluenceMonitoringMethodInterceptor.java:39)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
      com.sun.proxy.$Proxy249.deepCopy(Unknown Source)
      com.atlassian.confluence.api.impl.service.longtasks.BulkPageCopyTaskRunner.runTask(BulkPageCopyTaskRunner.java:150)
      

      IMPORTANT NOTE: This is also reproducible when attempting to copy a page using "Copy" option in the page meatballs menu.

      Workaround

      Manually upload a desired gif as an attachment and embed it from "Recently Uploaded" section.

      Attachments

        1. mismatch1.png
          mismatch1.png
          241 kB
        2. mismatch3.png
          mismatch3.png
          135 kB
        3. mistmatch2.png
          mistmatch2.png
          375 kB

        Issue Links

          Activity

            People

              bzivaljevic Bosko Zivaljevic (Inactive)
              rtoropov@atlassian.com Roman Toropov
              Votes:
              15 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: