chargebee / chargebee-dotnet

.NET library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=dotnet
MIT License
20 stars 24 forks source link

System.ArgumentException when parsing the test webhook payload #64

Open osilvaa opened 7 months ago

osilvaa commented 7 months ago

Description of the Bug

I'm getting a System.ArgumentException when I read the Event object after serialization using either of the supported methods provided by the SDK.

var eventDto1 = ApiConfig.DeserializeObject<Event>(jsonString); var eventDto2 = new Event(jsonString);

This is the error:

Property accessor 'Index' on object 'ChargeBee.Models.Subscription+SubscriptionShippingAddress' threw the following exception:'The property index is not present!' System.Reflection.TargetInvocationException: Property accessor 'Index' on object 'ChargeBee.Models.Subscription+SubscriptionShippingAddress' threw the following exception:'The property index is not present!' ---> System.ArgumentException: The property index is not present! at ChargeBee.Internal.Resource.ThrowIfKeyMissed(String key) at ChargeBee.Internal.Resource.GetValue[T](String key, Boolean required) at ChargeBee.Models.Subscription.SubscriptionShippingAddress.get_Index() at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Steps to reproduce

Described above.

Expected Behavior

A shipping address with no index shouldn't throw an exception. Similarly, the test webhook function should provide a payload that doesn't throw exceptions when hooked up with the provided client.

In our context, we have interceptors that look into the object properties.

Code Snippets (if applicable)

No response

Operating System

Windows

Language version

.NET8

Library version

v3.0.0 and 3.15.0

Additional context

No response

github-actions[bot] commented 7 months ago

Hello @osilvaa, thank you for raising the issue. Your contribution is greatly appreciated and we look forward to addressing it.