Jira throws "user exists but has no unique key mapping" on login, or throws "The JIRA server was contacted but has returned an error response" on searching for users in user picker field
問題
This KB article addresses these 2 main issues, 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.
Symptoms 1
- 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!
Symptoms 2
Login to JIRA fails after upgrade to JIRA 7.x;
The following error is shown in JIRA's 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/:?]
Symptoms 3
Searching some user in the project roles but hit into 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.
Symptoms 4
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' as shown below:
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)
原因
原因 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.
原因 2
The user cache is not flushed successfully.
Cause for Symptoms 4
It is a bug which will happen when renaming a username with Mixed Case. The bug in mention is - JRA-63109Getting issue details... STATUS with a workaround inside the bug report.
回避策
原因 1
データベースの変更を行う場合は 必ず事前にバックアップを取得してください。可能な場合はテスト サーバーで変更を試すことをおすすめします。
- Jira を停止します
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.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
andlower_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)
Execute the appropriate SQL query below, replacing
<username_identified
> with the affected username;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.
- Jira を起動します。
- Test by logging in as that user or re-enabling the JIRA Agile plugin, so the upgrade tasks fire again;
Second Workaround for Cause 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.
または
2) Insert your JIRA's license directly to your JIRA's database by following instruction from here.
Workaround for Cause 2 and Symptom 3
Refresh the User's Cache
Restarting Jira will clear the user's cache and recreate it once the application is started again. 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
Workaround for Symptoms 4
Upgrade to the bug fix version 7.2.6. Otherwise:
回避策
- Rename the user twice to a temporary username that had all lowercase character and then to the desired username. For example: _userOne > oneuser > userone_
- Jira を再起動します。
ソリューション
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.