Developer forum

Forum » CMS - Standard features » Duplicate key issue

Duplicate key issue

Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Hello,

I just upgraded a site to 9.12.3 (from 9.10.x) and I'm running into an issue: "An item with the same key has already been added."

I tracked it down to new code added a couple months ago in Frontend.ContentViewModelFactory.cs. (commit b32e0298). 

                    AddressCustomFields = GetCustomFieldValues(user.AddressCustomFieldValues),
                    CustomFields = GetCustomFieldValues(user.CustomFieldValues)

I've confirmed that the data itself doesn't have duplicate keys (custom user or address fields). One of those two lines must be generating a duplicate somehow. We notice the error when impersonating, but I don't know that it matters that it's impersonating. I believe it's just from the login on a customer account.

It can be reproed here: devupgrade-wolv.mydwsite3.com. You can create a simple login in the backend with impersonation access to any of the Customers -> All Customers. It fails on any customer that it impersonates. It's just a copy of a site so feel free to do what you want with it including changing any of the custom fields.

Thanks!

Scott


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi Scott,

I've had a look at your solution and saw some different results. I see the exception on saving new address in frontend only (note new address is created anyway). It occurs for user has no impersonation and OK otherwise. Please, try with 'dwtest2/dwtest2' and related 'dwtest1/dwtest1' users - OK but failed with 'dwtest5/dwtest5'. I've tried to check the same scenarios on Rapido 3.4.3 solution has added user custom/address fields like yours based on DW9.12.3 and was not able to catch the issue. It seem to be specific issue of your solution related to an customization etc. So, refer to support to have extra investigation if relevant.

BR, Oleg QA

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Hi Oleg,

It's been a while but I finally got back to this and I tracked down the issue. There was some code in one of our components from years ago which 'added' a new custom field value rather than updating the existing one. That caused a duplicate custom field value. In past versions of the platform, we got away with it by mistake. With the new version, it fails on the duplicates.

I've updated our code to fix this bug.

Thanks,

Scott

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi Scott,

Great, thanks for informing.

BR, Oleg QA

 

You must be logged in to post in the forum