Confluence import fails with a NullPointerException if the XML export has an attachment with just spaces as a file name

XMLWordPrintable

    • 16
    • Severity 3 - Minor
    • 1

      Issue Summary

      Because of bug CONFSERVER-74539 Confluence allows attachments with a file name with just blanks spaces.
      If this situation exists on an XML export, then the import fails with a NullPointerException.

      Steps to Reproduce

      1. Install a vanilla instance of Confluence.
        • This was validated on Confluence 7.13.0 and 7.4.11.
      2. Create a page with an attachment.
      3. Change the attachment name to just blank spaces.
      4. Go to Cog icon > General configuration > Backup & Restore.
      5. Create a site export.
      6. Move the generated export .zip file to <confluence-home>/restore
      7. Go to Cog icon > General configuration > Backup & Restore.
      8. Import the XML file.

      Expected Results

      Confluence completes the import, gracefully dealing with an attachment with just spaces as the title and lowertitle.

      Actual Results

      The import fails, mostly at the end of the operation >80%.
      The following entries are found on the application logs.

      2021-11-01 22:30:16,349 ERROR [Long running task: Importing data] [confluence.importexport.xmlimport.BackupImporter] importEntities Cannot import the entities: 
       -- url: /c7130/longrunningtaskxml.action | referer: http://localhost:27130/c7130/admin/restore-local-file.action | traceId: 7596f26feabbc969 | userName: admin | action: longrunningtaskxml
      java.lang.NullPointerException
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.doSpecialProcessing(BackupImporter.java:517)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.postProcess(BackupImporter.java:433)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:405)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEverything(BackupImporter.java:371)
      	at com.atlassian.confluence.importexport.xmlimport.FileBackupImporter.importEverything(FileBackupImporter.java:170)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter$1.doInTransactionWithoutResult(BackupImporter.java:262)
      	at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:36)
      	at com.atlassian.confluence.importexport.xmlimport.RestorePluginStateStoreTransactionCallbackDecorator.doInTransaction(RestorePluginStateStoreTransactionCallbackDecorator.java:49)
      	at com.atlassian.confluence.importexport.xmlimport.RestoreBandanaValuesTransactionCallbackDecorator.doInTransaction(RestoreBandanaValuesTransactionCallbackDecorator.java:56)
      (...)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      
      (...)
      
      2021-11-01 22:30:16,356 ERROR [Long running task: Importing data] [confluence.importexport.actions.ImportLongRunningTask] runInternal Failure during import
       -- url: /c7130/longrunningtaskxml.action | referer: http://localhost:27130/c7130/admin/restore-local-file.action | traceId: 7596f26feabbc969 | userName: admin | action: longrunningtaskxml
      com.atlassian.confluence.importexport.ImportExportException: java.lang.NullPointerException
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:410)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEverything(BackupImporter.java:371)
      	at com.atlassian.confluence.importexport.xmlimport.FileBackupImporter.importEverything(FileBackupImporter.java:170)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter$1.doInTransactionWithoutResult(BackupImporter.java:262)
      	at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:36)
      (...)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.NullPointerException
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.doSpecialProcessing(BackupImporter.java:517)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.postProcess(BackupImporter.java:433)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:405)
      	... 38 more
      

      Workaround

      If the source instance is still available, then the administrator can:

      1. Search for the attachments on which the file name is just blank spaces.
      2. Change the file name to something meaningful.
      3. Create a new export.

      If the source instance isn't available anymore then the administrator can manually edit the entities.xml file of the available XML export, changing the attachment name directly in the file and creating a new .zip file with the modified entities.xml.
      You may choose opening a request to Atlassian Support to get help identifying this situation and making the appropriate changes to that file.

      One alternative to search for the affected attachments is to run a query at the database level to find all of them. Here's an example of a query to search for attachments with blank spaces as names in an Oracle database:

      SELECT * FROM content WHERE contenttype = 'ATTACHMENT' AND TRIM(title) IS NULL;
      

            Assignee:
            Anshul Chokhani
            Reporter:
            Thiago Masutti (Inactive)
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: