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

XML import fails with a unique constraint violation when a user contains a space at the end of a duplicated username

    XMLWordPrintable

Details

    Description

      Issue Summary

      It's currently possible to synchronise users when their username ends with a space. Therefore, it makes it possible for these 2 users to exist in Confluence:

      • "admin" - (no space at the end)
      • "admin " - (with a space at the end)

      This is detected as 2 different users in Confluence and both users will have separate records in the cwd_user and user_mapping table.

      If you export the site to XML and attempt to re-import it later, the import will fail due to a unique constraint violation.

      Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "unq_lwr_username"
        Detail: Key (lower_username)=(admin) already exists. 

      The import process in Confluence strips the space at the end of the username, which results in Confluence attempting to insert the same username into the user_mapping table twice.

      Steps to Reproduce

      1. Synchronise 2 users to Confluence with identical usernames but one of them has a space at the end of their username.
      2. Export the site to XML.
      3. Create a new instance of the same version.
      4. Import the XML backup.

      Expected Results

      The XML restoration should succeed with no errors.

      Actual Results

      The XML restoration fails with the below exception thrown in the atlassian-confluence.log file:

      2021-11-12 11:03:38,069 ERROR [Long running task: Importing data] [confluence.importexport.xmlimport.BackupImporter] importEntities Cannot import the entities: 
       -- url: /longrunningtaskxml.action | referer: http://localhost:8090/admin/restore.action?synchronous=false | traceId: 01ac10c83e84fca5 | userName: admin | action: longrunningtaskxml
      com.atlassian.confluence.importexport.ImportExportException: Unable to complete import because the data does not match the constraints in the Confluence schema. Cause: PSQLException: ERROR: duplicate key value violates unique constraint "unq_lwr_username"
        Detail: Key (lower_username)=(admin) already exists. 

      Workaround

      Ensure each user's username in Confluence is unique and not differentiated via a space character at the end of their username.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              azolkefli Athirah Zolkefli
              Votes:
              6 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: