Unable to rename key when there are duplicates of the key

versions used: Sonar 5.6.6, Sonar Maven Plugin 3.4.0.905

Recently we changed the group ID of our maven projects. To ensure that our analysis results would still go to the same project in Sonar I updated the keys for our project. However since we had maven projects whose artifact ID was the same as the old group ID, as well as other projects whose artifact ID was the same as the new group ID this resulted in me creating a configuration with duplicate keys.

ie.

A:A
A:B

Bulk Key update of A -> B

B:B
B:B

Subsequently when analysis was performed we got the following error

java.lang.IllegalArgumentException: Multiple entries with same key: B:B=org.sonar.db.component.ComponentDto@62c0dd74[id=68041,uuid=AWtv-Hz13AwaM3pbERUp,kee=B:B,scope=PRJ,qualifier=BRC,projectUuid=c4b4622f-4b21-4027-a98f-8f8cc7cb69a8,moduleUuid=383bc8e3-1d53-4645-8788-379a941ebe37,moduleUuidPath=.c4b4622f-4b21-4027-a98f-8f8cc7cb69a8.383bc8e3-1d53-4645-8788-379a941ebe37.AWtv-Hz13AwaM3pbERUp.,parentProjectId=23806,copyResourceId=<null>,developerId=<null>,path=B,deprecatedKey=B:B,name=Name B,longName=Name B,language=<null>,enabled=true,authorizationUpdatedAt=<null>] and B:B=org.sonar.db.component.ComponentDto@65b10962[id=30375,uuid=a1415d3e-f81e-4746-8e59-1a097dd0aa6d,kee=B:B,scope=PRJ,qualifier=BRC,projectUuid=c4b4622f-4b21-4027-a98f-8f8cc7cb69a8,moduleUuid=0500a91b-54e3-4223-aa48-f08c5d997129,moduleUuidPath=.c4b4622f-4b21-4027-a98f-8f8cc7cb69a8.0500a91b-54e3-4223-aa48-f08c5d997129.a1415d3e-f81e-4746-8e59-1a097dd0aa6d.,parentProjectId=23806,copyResourceId=<null>,developerId=<null>,path=A,deprecatedKey=B:B,name=Name A,longName=Name A,language=<null>,enabled=false,authorizationUpdatedAt=<null>]

Realizing my mistake I went to manually update the keys under project administration to fix the duplication, however Sonar errored when I tried to change one of the duplicate keys, redirecting me to a generic error page suggesting that I contact support.

The most frustrating part is that one of the duplicated keys refers to a project that no longer exists, however I can see no way to delete the key in sonar.

We ended up resolving this issue by manually editing the project keys in the database to get rid of the duplicated keys. After this our analysis was able to proceed without issue.