"No unique key mapping" error on login or failure to search user picker field

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

There are two main presentations of this problem, which are both due to the same root cause:

  • Login attempts into Jira fail with the following error:

    User exists but has no unique key mapping

     

  • When searching for users in any user picker field (or in the project role configuration page), Jira throws the following error:

    The JIRA server was contacted but has returned an error response. We are unsure of the result of this operation.

     

Diagnosis 1: Post-6.x Jira upgrade

  • Login to Jira fails after upgrade to Jira 6.x;
  • Jira Agile (Greenhopper) upgrades fail to complete;

The following appears in the atlassian-jira.log whan an affected user tries to login.

java.lang.IllegalStateException: User 'xxxx' exists but has no unique key mapping.
	at com.atlassian.jira.user.util.DefaultUserManager.getUserByName(DefaultUserManager.java:262)
	at com.atlassian.jira.security.login.JiraSeraphAuthenticator.getUser(JiraSeraphAuthenticator.java:36)
	at com.atlassian.seraph.auth.DefaultAuthenticator.login(DefaultAuthenticator.java:101)
	at com.atlassian.seraph.filter.PasswordBasedLoginFilter.runAuthentication(PasswordBasedLoginFilter.java:127)

The below appears during a GreenHopper upgrade.

2013-08-05 17:45:50,034 http-bio-8090-exec-14 ERROR potatobake 1065x2431x1 b4cq2t 192.168.131.14 /rest/plugins/1.0/com.pyxis.greenhopper.jira-key [sal.core.upgrade.PluginUpgrader] Upgrade failed: null
java.lang.NullPointerException
	at com.atlassian.greenhopper.upgrade.GhUpgradeTask003.movePreferencesToSettings(GhUpgradeTask003.java:90)
	at com.atlassian.greenhopper.upgrade.GhUpgradeTask003.doUpgrade(GhUpgradeTask003.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)

The below message can also appear in other logs for operations that require a login.

com.atlassian.jira.util.dbc.Assertions$NullArgumentException :key should not be null!

Diagnosis 2: Post-7.x Jira upgrade

Login to Jira fails after upgrade to JIRA 7.x;

The following error is shown in Jira UI when user tries to enter license:

Cause
Referer URL: http://192.168.178.30:1337/secure/ConfirmNewInstallationWithOldLicense.jspa
java.lang.IllegalStateException: User 'vicky' has no unique key mapping.
java.lang.IllegalStateException: User 'vicky' has no unique key mapping.
        at com.atlassian.jira.user.ApplicationUsers.from(ApplicationUsers.java:46) [classes/:?]
        at com.atlassian.jira.web.action.admin.ConfirmNewInstallationWithOldLicense.getCrowdUser(ConfirmNewInstallationWithOldLicense.java:229) [classes/:?]
        at com.atlassian.jira.web.action.admin.ConfirmNewInstallationWithOldLicense.doValidation(ConfirmNewInstallationWithOldLicense.java:197) [classes/:?]

Diagnosis 3: Search failures at project roles screen

Searching some users in the project roles generate the following errors:

2016-09-16 12:26:42,144 http-nio-8080-exec-5 ERROR xxxx xxx xxxxxx xx.x.x.x /rest/api/2/groupuserpicker [c.a.j.rest.exception.ExceptionInterceptor] Returning internal server error in response
java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.IllegalStateException: User 'xxxx' has no unique key mapping. 

Diagnosis 4: Search failures in any user picker field

Searching for a user in any User Picker field will pop-up an error 'The JIRA server was contacted but has returned an error response. We are unsure of the result of this operation.'

With stack trace inside atlassian-jira.log

2016-11-09 15:27:22,469 http-nio-8723-exec-10 ERROR admin 927x6717x1 1h7zv5i 10.60.6.142 /rest/api/1.0/users/picker [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: User 'Usersatu' has no unique key mapping.
java.lang.IllegalStateException: User 'Usersatu' has no unique key mapping.
	at com.atlassian.jira.user.ApplicationUsers.from(ApplicationUsers.java:46)
	at com.atlassian.jira.user.ApplicationUsers.from(ApplicationUsers.java:143)
	at com.atlassian.jira.bc.user.search.DefaultUserPickerSearchService$ApplicationUserResultType.convertCrowdResults(DefaultUserPickerSearchService.java:689)


Cause list

Cause for Diagnosis 1

JIRA 6.0 introduced the "Rename User" feature which added a new app_user table to store the user name mappings. The failure reported here appears to be caused by an error during an upgrade task, which was tracked in the below bug report.

This can also be caused if any modification to data in either the app_user or the cwd_user tables was made directly on JIRA's database.

Cause for Diagnosis 2 and 3

The user cache is not flushed successfully. 

Cause for Diagnosis 4

It is a bug which will happen when renaming a username with Mixed Case. The bug in mention is JRASERVER-63109 - Jira displays an error when searching for a username that has been renamed from mixed case with a workaround inside the bug report.

Workaround

Solution for Diagnosis 1

Always back up your data before performing any modification to the database. If possible, try your modifications on a test server.

  1. Stop JIRA;
  2. Execute the below SQL to identify the problematic user/s;

    SELECT
        lower_user_name
    FROM
        cwd_user
    WHERE
        lower_user_name NOT IN (
            SELECT lower_user_name FROM app_user
    );

    Postgres: If you have a large number of users and the above query is non performant, try this:

    SELECT u.lower_user_name FROM cwd_user u WHERE NOT EXISTS (SELECT a.lower_user_name FROM app_user a where u.lower_user_name = a.lower_user_name);

    Additionally, sometimes the atlassian-jira.log will show the name of users affected by the problem in the aforementioned errors . For example: "User 'problem.user' has no unique key mapping" can indicate a user that is contributing to this problem. If the preceding query does not return any results, looking for the errors in your logs might also yield problematic usernames.

    The statement may not work on MySQL DBMS, in that case run the below instead.

    SELECT
        lower_user_name
    FROM
        cwd_user
    WHERE
        BINARY lower_user_name NOT IN (
            SELECT BINARY lower_user_name FROM app_user
    );
  3. Check if the user(s) retrieved with the query above have an existing entry;

    SELECT * FROM app_user WHERE lower_user_name = '<username_identified>' OR user_key = '<username_identified>';

    If the username already has an entry, update that entry so that both user_key and lower_user_name values match the expected username instead of adding a new entry with the step below.

    (In a later Jira version where user_key has value like JIRAUSER10200, update the entry so that lower_user_name in app_user table matches the lower_user_name in cwd_user table)

  4. Execute the appropriate SQL query below,  replacing <username_identified> with the affected username; 
    PostgreSQL

    INSERT INTO app_user 
    VALUES (
    	(SELECT max(id) + 1 FROM app_user),
    	'username_identified',
    	'username_identified'
    ); 
    
    # The below query only applies to JIRA 6.1 and above, in order to 
    update the sequence value and ensure we don't get duplicate ID's. 
    If above version 6.1, you'll run this query after the first query 
    has added the user to the 'app_user' table.
    
    
    UPDATE sequence_value_item 
    SET seq_id = (SELECT max(id) FROM app_user) + 10 
    WHERE seq_name = 'ApplicationUser';

    MySQL

    INSERT INTO app_user 
    SELECT (max(id) + 1),
        'username_identified',
        'username_identified' 
    FROM app_user;
    
    
    # The below query only applies to JIRA 6.1 and above, in order to 
    update the sequence value and ensure we don't get duplicate ID's. 
    If above version 6.1, you'll run this query after the first query 
    has added the user to the 'app_user' table.
    
    
    UPDATE SEQUENCE_VALUE_ITEM 
    SET seq_id = (SELECT max(id) FROM app_user) + 10 
    WHERE seq_name = 'ApplicationUser'; 

    SQL Server

    # Fetch the ID to use. This ID will be used in the next SQL query.
    
    SELECT max(id) FROM app_user;
    
    # Take a note of the above query, increase the value by 1 and use it on the following query.
    # For example, if max(id) returns 123, the value you need to use is 124 (id from previous query + 1)
    
    INSERT INTO app_user 
    VALUES ('<id from previous query + 1>',
           'username_identified', 
           'username_identified');
     
    # The below query only applies to JIRA 6.1 and above, in order to 
    update the sequence value and ensure we don't get duplicate ID's. 
    If above version 6.1, you'll run this query after the first query 
    has added the user to the 'app_user' table.
    
    
    UPDATE sequence_value_item 
    SET seq_id = <id from previous query + 10> 
    WHERE seq_name = 'ApplicationUser';

    Oracle

    INSERT INTO app_user 
    
    VALUES (
    	(SELECT ( max(id) + 1 ) from app_user), 
    	'username_identified', 
    	'username_identified'
    );
     
    # The below query only applies to JIRA 6.1 and above, in order to 
    update the sequence value and ensure we don't get duplicate ID's. 
    If above version 6.1, you'll run this query after the first query 
    has added the user to the 'app_user' table.
    
    
    UPDATE sequence_value_item 
    SET seq_id=(SELECT ((MAX(id)+10)) FROM app_user) 
    WHERE seq_name = 'ApplicationUser';	
     
    # commit the changes
    COMMIT;

    In case the above query does not return any results and JIRA is integrated with a LDAP server or Crowd, there could be a similar user mapping problem with installing/upgrading JIRA Agile. Then, the workaround is to add a Internal Directory user, disable the external User Directory and try installing JIRA Agile again.

  5. Start JIRA.
  6. Test by logging in as that user or re-enabling the JIRA Agile plugin, so the upgrade tasks fire again;

Second Solution for Diagnosis 1

There can be 2 workarounds for the error after entering the license:

1)

  • Please chose to start with ”Evaluation Terms”
  • Create a new Evaluation License and proceed to access your JIRA.

  • Please navigate to *Versions and Licensing* page (Type {{gg}} and enter {{Versions and Licensing}} to access the page).

  • Enter you JIRA's commercial license key.

or

2) Insert your JIRA's license directly to your JIRA's database by following instruction from here.

Solution for Diagnosis 2 and 3

Refresh the User's Cache

Restarting Jira will clear the user's cache and recreate it once the application is started again.
(info) If you have a Data Center installation, all Nodes must be stopped and then started one by one, otherwise the problematic cache can be replicated back to the starting Nodes

Solution for Diagnosis 4

Upgrade to the bug fix version 7.2.6. Otherwise:

Workaround

  • Rename the user twice to a temporary username that had all lowercase character and then to the desired username. For example: _userOne > oneuser > userone_
  • Restart JIRA

Resolution

Jira Portfolio

For errors from JIRA Portfolio, the problem is tracked at the below bug report. For now, the workaround steps above are necessary.

JIRA Agile

Errors on JIRA Agile (GreenHopper), were resolved on JIRA 6.1 and above, as described on the below bug report.

DescriptionLogin attempts into JIRA fail with the following error, 'User exists but has no unique key mapping'
ProductJira
PlatformServer


 
Last modified on Feb 28, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.