Closed colorful3 closed 3 years ago
描述 bug
你是如何操作的? 后端接口的 DTO 对象中定义一个列表类型参数;前端故意将参数类型传错,把请求 body 里面的列表类型参数改为整型或字符串类型。
发生了什么?
后端返回的报错为:
{ "code": 10030, "message": "请求体不可为空", "request": "PUT /cms/admin/user/2" }
(截图为”管理员更新用户信息”的接口请求)
{ "code": 10030, "message": "group_ids字段类型错误", "request": "PUT /cms/admin/user/2" }
请求体不可为空的报错信息非常模糊,对前端误导性极强。
你使用哪个版本出现该问题?
如果使用master,请表明是 master 分支,否则给出具体的版本号 master 分支,0.2.0-RC2 版本。
master
If your bug is deterministic, can you give a minimal reproducing code? Some bugs are not deterministic. Can you describe with precision in which context it happened? If this is possible, can you share your code? 修改如下代码: https://github.com/TaleLin/lin-cms-spring-boot/blob/bd6b0c8692b95bafd14b8ba0585ebb64b35d8788/src/main/java/io/github/talelin/latticy/common/exception/RestExceptionHandler.java#L191-L205
@colorful3 这个字段类型不匹配的问题可以考虑在控制器里面通过@valid 注解进行参数做吗? 这样的话就可以保证返回的错误消息比较准确
@colorful3 已解决
描述 bug
你是如何操作的? 后端接口的 DTO 对象中定义一个列表类型参数;前端故意将参数类型传错,把请求 body 里面的列表类型参数改为整型或字符串类型。
发生了什么?
后端返回的报错为:
(截图为”管理员更新用户信息”的接口请求)
请求体不可为空的报错信息非常模糊,对前端误导性极强。
你使用哪个版本出现该问题?
如果使用
master
,请表明是 master 分支,否则给出具体的版本号 master 分支,0.2.0-RC2 版本。If your bug is deterministic, can you give a minimal reproducing code? Some bugs are not deterministic. Can you describe with precision in which context it happened? If this is possible, can you share your code? 修改如下代码: https://github.com/TaleLin/lin-cms-spring-boot/blob/bd6b0c8692b95bafd14b8ba0585ebb64b35d8788/src/main/java/io/github/talelin/latticy/common/exception/RestExceptionHandler.java#L191-L205