brandonseydel/MailChimp.Net

Acessing MailChimpException.Data throws System.ArgumentException after upgrade to 3.4.1 version

Closed this issue · 6 comments

Upgraded MailChimp.Net from 3.2.1 to 3.4.1.
It destroyed our production environment, as our Azure Table logging crashes the whole process, because exception serialization fails inside .net framework code, because of the Data property throwing this exception.

I have seen this in two scenarios calling Members.AddOrUpdateAsync (i guess all mailchimp exception currently have this problem):

  1. Exception when i cannot change email of unsubscribed member
  2. Exception when i cannot add a new member, which was already permanently deleted

The latest version is 4.2.0. Can you bump your nuget to that as it works correctly? I replicated what you are saying on latest and it correctly caught the error.

Sorry, i actually updated version from 2.1 to 4.1 (the 3 before the version came from the name of the library:)
Now, after updated to 4.2, the issue is still there.
image

eibx commented

We're also experiencing this.

I made a PR a while ago to fix a similar issue regarding accessing Data twice, giving the same error.

I would assume this issue occurs because the base.Data inside MailChimpException.cs already contains one of the properties detail, title, type, status, instance, errors or rawhttpresponsemessage - and adding the same key twice to a dictionary throws an System.ArgumentException.

I think there are 3 ways to solve it.

  1. Is to overwrite the property using data["detail"] = Detail instead of data.Add - this will of course overwrite potentional important information.

  2. Is to change the property keys either by giving them different names or by prefixing them with something. This might be a breaking change, and will only make the issue less likely.

  3. Make some logic that suffixes an incremental number as long as the key is present in the dictionary. This makes the method more complicated and might be overkill, but no data is lost and it retains the original names unless an duplicate is found.

eibx commented

@brandonseydel If you have any preferences to my comment above or any suggestion of your own, I'll be more than happy to make a pull request.

@brandonseydel It would be great if you would comment on @eibx 's comment

Stale issue message