Rock icon indicating copy to clipboard operation
Rock copied to clipboard

BusinessDetail ShowSummary supports loading multiple previous addresses, but crashes during load

Open erickpece opened this issue 1 year ago • 0 comments

Description

When loading a Business Profile that has multiple Previous Addresses, the following error is thrown:

An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Rock.Web.DescriptionList.Add(String term, Object description, Boolean showIfBlank) in \Rock\Web\DescriptionList.cs:line 48
   at RockWeb.Blocks.Finance.BusinessDetail.ShowSummary(Int32 businessId)
   at RockWeb.Blocks.Finance.BusinessDetail.ShowDetail(Int32 businessId)
   at RockWeb.Blocks.Finance.BusinessDetail.OnLoad(EventArgs e)
   at Rock.Web.RockControlAdapter.OnLoad(EventArgs e) in \Rock\Web\RockControlAdapter.cs:line 71
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I tracked this down to the // Get addresses section of the code, between lines 742 and 770, where previous locations are loaded. After manually removing all but the most recently updated previous addresses, the error stopped and we were able to view business profiles.

In addition, when changing the address in the profile, if the Save Former Address As Previous Address box is checked, the page will crash if a previous address already exists.

Actual Behavior

If more than one address is present, the business profile page crashes.

Expected Behavior

If more than one previous address is supported, then the duplicate key error should be fixed, and adding multiple previous addresses should be supported on the page. If not, remove the option to add previous addresses.

Steps to Reproduce

I'm not sure how we ended up with multiple previous addresses, but to reproduce the addition bug:

  1. Go to a business profile.
  2. Click Edit.
  3. Enter an address.
  4. Check the Save Former Address As Previous Address box.
  5. Click Save.
  6. Repeat steps 2-5 and observe the adding error.

Issue Confirmation

  • [X] Perform a search on the Github Issues to see if your bug or enhancement is already reported.
  • [X] Try to reproduce the problem on a fresh install or on the demo site.

Rock Version

16.3

Client Culture Setting

en-US

erickpece avatar Apr 15 '24 20:04 erickpece