Creating issues throws error Multiple entries with same key in Jira server

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

Problem

When attempting to create an issue, the following error is thrown on the Create Issue screen:

java.lang.IllegalArgumentException: Multiple entries with same key: 
customfield_14469=com.atlassian.jira.rest.v2.issue.IssueBeanBuilder2$FieldData@3ee1f3ed 
and customfield_14469=com.atlassian.jira.rest.v2.issue.IssueBeanBuilder2$FieldData@753d8ff


The following appears in the atlassian-jira.log

2016-xx-xx 15:24:00,245 http-nio-xxxx-exec-13 ERROR xxx xxx uq8kvc xxx,xxx /rest/api/2/issue/ISSUEKEY-10000 [c.a.j.rest.exception.ExceptionInterceptor] Returning internal server error in response
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper$ResponseOutInvoker$1.invoke(DispatchProviderHelper.java:234)
	... 4 filtered
	at com.atlassian.jira.rest.exception.ExceptionInterceptor.intercept(ExceptionInterceptor.java:55)
	... 1 filtered
	...
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Multiple entries with same key: customfield_14469=com.atlassian.jira.rest.v2.issue.IssueBeanBuilder2$FieldData@3ee1f3ed and customfield_14469=com.atlassian.jira.rest.v2.issue.IssueBeanBuilder2$FieldData@753d8ff
	at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:150)
	at com.google.common.collect.RegularImmutableMap.checkNoConflictInBucket(RegularImmutableMap.java:104)
	at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:70)
	at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:254)
	at com.google.common.collect.Maps.uniqueIndex(Maps.java:1166)
	at com.atlassian.jira.rest.v2.issue.IssueBeanBuilder2.createFieldsData(IssueBeanBuilder2.java:211)
	at com.atlassian.jira.rest.v2.issue.IssueBeanBuilder2.build(IssueBeanBuilder2.java:149)
	at com.atlassian.jira.rest.v2.issue.IssueResource.getIssue(IssueResource.java:400)
	... 221 more

Diagnosis

Environment

Instance is running on JIRA 7.0 or newer. 

Cause

There are multiple entries of the same custom field in the affected project's Field Configuration. 

Verification Method #1:

  1. For example, screenshot below shows an example of 2 Epic Color fields in the same Field Configuration:
     
  2. It is possible to have multiple custom fields with the same name. However this problem relates to a single field having multiple configs in the Field Configuration. Hence the duplication of the config also needs to be verified from the database side.
    Run the following SQL to identify this:

    SELECT * FROM fieldlayoutitem WHERE FIELDIDENTIFIER = 'customfield_10004' 
    AND FIELDLAYOUT = (SELECT ID FROM fieldlayout WHERE NAME = 'Default Field Configuration');

    (warning) Replace "Default Field Configuration" with the name of the field configuration. 

    (warning) Replace "customfield_10004" with the customfield ID from the error message in the stack trace:

    Multiple entries with same key: customfield_xxxxx
  3. The SQL in step #2 should return only one entry:

    (info) This means that this field (ID 10004) only has a single entry for this field configuration. 
     

  4. If two entries are returned similar to the following, then this is the root cause of the problem.


  5. It is possible that after fixing one entry with the work-around below, that you might have other fields that also have duplicate field configurations.   In those cases it might help to identify all the field configurations that have been duplicated on that specific field configuration.   You can do this with the SQL select statement such as:

    SELECT * FROM fieldlayoutitem WHERE FIELDIDENTIFIER LIKE '%'
    AND FIELDLAYOUT = (SELECT ID FROM fieldlayout WHERE NAME = 'Default Field Configuration') 
    ORDER BY fieldidentifier;

Verification Method #2:

The query below will check all records from fieldlayoutitem  table and display entries that should be removed. It was written for PostgreSQL so it may require tweaking for other DB products.

  • It returns all entries except oldest one for impacted records with the same fieldlayout/fieldidentifier pair:
select distinct a.* from fieldlayoutitem a, fieldlayoutitem b where a.id > b.id and a.fieldlayout = b.fieldlayout and a.fieldidentifier = b.fieldidentifier;

If you'd like to also see the Field Configuration name associated with the duplicate entry, you can join the query above on fieldlayout table (note that only records from fieldlayoutitem are to be deleted - the query below is meant for doublechecking the results above):

select distinct a.*,fl.name,fl.description from fieldlayoutitem a, fieldlayoutitem b left join fieldlayout fl on a.fieldlayout = fl.id where a.id > b.id and a.fieldlayout = b.fieldlayout and a.fieldidentifier = b.fieldidentifier;


Workaround

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

Option #1:

Delete the duplicated field configuration directly. It does not matter which one of it is deleted, as long as only one row remains. (Example: if you have 3 duplicates, delete 2 of them)

Follow these steps:

  • Stop the JIRA instance.

  • Run the following SQL to delete the duplicated config:

    DELETE FROM fieldlayoutitem WHERE ID = 10225 AND FIELDIDENTIFIER = 'customfield_10004';


    Replace the ID in the query above with the appropriate ID from your SQL results. In this case, I am deleting one of the entries from here: 

  • Restart JIRA. 

Option #2:

While the first option is more specific and detailed, it may not be applicable if the number of duplicates is too high. Minor tweaking might be needed for other DB products.

  • Stop the JIRA instance.
  • Run this query to get all the results to be deleted if needed for troubleshooting afterwards:
select distinct a.* from fieldlayoutitem a, fieldlayoutitem b where a.id > b.id and a.fieldlayout = b.fieldlayout and a.fieldidentifier = b.fieldidentifier;
  • Run the delete statement below (NOTE: Depending on the database platform, this query may need to be modified to address syntax issues.  Please see your database platforms documentation for assistance in those cases):
DELETE FROM fieldlayoutitem a USING fieldlayoutitem b WHERE a.id > b.id AND a.fieldlayout = b.fieldlayout AND a.fieldidentifier = b.fieldidentifier;

# MSSQL 
DELETE a FROM fieldlayoutitem a INNER JOIN fieldlayoutitem b ON a.fieldlayout = b.fieldlayout AND a.fieldidentifier = b.fieldidentifier AND a.id > b.id 

# MySQL
DELETE e.* FROM fieldlayoutitem e WHERE e.id in (select id FROM (SELECT a.id FROM fieldlayoutitem a INNER JOIN fieldlayoutitem b ON a.fieldlayout = b.fieldlayout AND a.fieldidentifier = b.fieldidentifier WHERE a.id > b.id) x);

# PostgreSQL
DELETE FROM fieldlayoutitem e WHERE e.id in (select id FROM (select a.id FROM fieldlayoutitem a INNER JOIN fieldlayoutitem b ON a.fieldlayout = b.fieldlayout AND  a.fieldidentifier = b.fieldidentifier WHERE a.id > b.id) x); 
  • Restart JIRA. 

Resolution

It is currently unknown on how these duplications could occur. It is recommended to check if you have custom add-ons or customisations that may incorrectly manipulate Field Configuration Schemes or field configurations, and raise it to the appropriate add-on developer for further assistance. 




Last modified on May 16, 2023

Was this helpful?

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