API error shadowed by ClassCastException message if error is not a json object
维护者通常 3 天内回复
@remi-stripe 已经在做这个了。
开始于 2024年8月8日。
评估
这个 Issue 还没有评估数据。
描述
Describe the bug
Using some stripebased payments, when an unsuccessful response is resived, the "error" field in the body may be a string instead of a correct json object in raw response
While parsing the error in the com.stripe.net.LiveStripeResponseGetter#handleApiError method, a ClassCastException error is thrown which is thrown out and is uninformative to the sdk consumer
To Reproduce
- Make any api call that returns a non json type error
- Get exception
java.lang.ClassCastException: class com.google.gson.JsonPrimitive cannot be cast to class com.google.gson.JsonObject
Expected behavior
It is expected that any api call with an error will throw a StripeException or its child exception with a message from the api
Code snippets
No response
OS
all
Java version
21
stripe-java version
26.1.0
API version
2024-06-20
Additional context
try {
JsonObject jsonObject =
ApiResource.INTERNAL_GSON
.fromJson(response.body(), JsonObject.class)
.getAsJsonObject("error");
error = ApiResource.deserializeStripeObject(jsonObject.toString(), StripeError.class, this);
} catch (JsonSyntaxException e) {
raiseMalformedJsonError(response.body(), response.code(), response.requestId(), e);
}
The issue here getAsJsonObject("error")
I think that just need to add ClassCastException to the catch block
- 主要语言
- Java
- 星标
- 1k
- 派生
- 412
- 平均合并
- 4 天 12 小时
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
stripe/stripe-java 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
stripe/stripe-java#2341 ·
维护者通常 3 天内回复
-
Use JSpecify’s annotations to document nullability可能重新可做 @Parthiee 于 410 天前认领,目前没有进行中的 PR。 未关闭feature-request future
难度 4/5 3-5 天 新手友好度 42/100
stripe/stripe-java#2024 · 5 条评论 · 3 个 reaction ·
维护者通常 3 天内回复
-
feature-request future
难度 3/5 1-2 天 新手友好度 45/100
stripe/stripe-java#2012 · 5 条评论 ·
维护者通常 3 天内回复
-
feature-request future
难度 5/5 一周以上 新手友好度 25/100
stripe/stripe-java#1964 · 1 条评论 ·
维护者通常 3 天内回复
-
feature-request future
难度 5/5 一周以上 新手友好度 35/100
stripe/stripe-java#1905 · 8 条评论 · 7 个 reaction ·
维护者通常 3 天内回复
查看 stripe/stripe-java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 79/100
micronaut-projects/micronaut-core#14585 ·
维护者通常 1 天内回复
-
Mend: dependency security vulnerability untriaged
难度 1/5 1 小时以内 新手友好度 78/100
opensearch-project/cross-cluster-replication#1805 ·
维护者通常 1 天内回复
-
feature request needs triage
难度 1/5 1 小时以内 新手友好度 66/100
TeamNewPipe/NewPipe#14083 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
PCL-Community/PCL-CE#3907 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 2 天内回复