Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-65482

Confluence XML space import accepts files with inconsistencies

    XMLWordPrintable

Details

    Description

      Problem

      Importing an XML space backup with inconsistencies completes, even though there are problems with its contents.

      Steps to Reproduce

      1. Create a space XML backup
      2. Extract the files and edit the entities.xml
      3. Replace all the lower space key entries with their upper case equivalents, example:
        • Original:
          <property name="key"><![CDATA[TST]]></property>
          <property name="lowerKey"><![CDATA[tst]]></property>
          
        • Modified:
          <property name="key"><![CDATA[TST]]></property>
          <property name="lowerKey"><![CDATA[TST]]></property>
          
      4. Create a new zip with the modified file and import the space

      Expected Results

      The import fails due to that problem or the key is converted to lower case before inserting into the database (lowerspacekey from spaces).

      Actual Results

      The import does not throw any error on the UI, so it looks successful. The following can be seen in the atlassian-confluence.log:

      2021-05-14 17:26:26,155 ERROR [Long running task: Importing data] [confluence.pages.ancestors.RebuildAncestorsPostImportTask] rebuildPageAncestors Could not load valid space for imported space key: TST
       -- url: /admin/restore.action | referer: http://localhost:8090/admin/backup.action | traceId: ea82dd8239cdce28 | userName: admin | action: restore
      2021-05-14 17:26:26,192 WARN [AtlassianEvent::CustomizableThreadFactory-1] [gatekeeper.evaluator.cache.CacheUpdateSender] warn Space import for spaceKey TST did not import correctly. Unable to retrieve the space for permission cache update.
       -- url: /admin/restore.action | referer: http://localhost:8090/admin/backup.action | traceId: ea82dd8239cdce28 | userName: admin | action: restore
      2021-05-14 17:26:26,196 INFO [Long running task: Importing data] [confluence.importexport.actions.ImportLongRunningTask] runInternal Finished import.
      

      At this stage, the space is not functional. Trying to open pages results in 404 errors and neither the page tree nor the space tools load properly. Checking the database, you can confirm that the lowerspacekey column of the spaces table is holding the upper case key.

      Workaround

      1. Stop Confluence
      2. Take a database backup
      3. Run the following query to set the lower space key:
        Replace the key accordingly
        update spaces 
        set lowerspacekey = '<LOWERCASE-KEY>' 
        where spacekey = '<UPPERCASE-KEY>';
        
      4. Restart Confluence
      5. Rebuild the indexes and the ancestors table as follows, one at a time:

      Notes

      This problem can easily happen when trying to change a space key as covered here:

      During the XML manipulation, space keys can be renamed incorrectly leading to this issue.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bandreeti Bernardo Andreeti
              Votes:
              6 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated: