You have tried to add a duplicate key for a key which you have not defined as being able to have duplicates.
As this error implies that your program logic contains a mistake, you probably should recode.