stripe-java icon indicating copy to clipboard operation
stripe-java copied to clipboard

stripeClient throw JsonSyntaxException instead of StripeException

Open julienmweb opened this issue 1 year ago • 1 comments

Describe the bug

Hi After upgrading the com.stripe:stripe-java dependency from version 26.9.0 to 26.11.0, a test in our project fails:

The test expects stripeClient to throw a StripeException, but instead, a com.google.gson.JsonSyntaxException is thrown. It looks like the JsonSyntaxException is thrown directly instead of being encapsulated within a StripeException like in the previous version

To Reproduce

Create a test: Configure WireMock to return an invalid JSON response when the stripeClient do a call a JsonSyntaxException should be thrown

java.lang.AssertionError: Expecting actual throwable to be an instance of: com.stripe.exception.StripeException but was: com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive; at path $ at com.google.gson.internal.bind.TypeAdapters$34$1.read(TypeAdapters.java:1152) at com.google.gson.Gson.fromJson(Gson.java:1361) at com.google.gson.Gson.fromJson(Gson.java:1262) ...(93 remaining lines not displayed - this can be changed with Assertions.setMaxStackTraceElementsDisplayed)

Expected behavior

stripeClient should throw a StripeException

Code snippets

No response

OS

linux

Java version

21

stripe-java version

v26.11.0

API version

2024-06-20

Additional context

No response

julienmweb avatar Sep 18 '24 12:09 julienmweb

Thanks for reporting @julienmweb We will add this to our backlog

ramya-stripe avatar Sep 23 '24 16:09 ramya-stripe

Hello, we face the same problem and it prevents us from upgrading: version 28.0.0 is also causing the same kind of issue

Is there a way to prioritise it ? 🙏

mmvaubrun avatar Nov 05 '24 10:11 mmvaubrun

Hi, sorry about the delay and trouble caused here! We are looking into this issue.

helenye-stripe avatar Nov 05 '24 22:11 helenye-stripe

This is fixed in the new release v28.0.1!

helenye-stripe avatar Nov 06 '24 22:11 helenye-stripe

thank you !🙏

julienmweb avatar Nov 06 '24 22:11 julienmweb