Incorrect JSON deserialization in `handleOneWayDeviceRPCRequestV2WithHttpInfo`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
Hướng nghiên cứu
Tìm handleOneWayDeviceRPCRequestV2WithHttpInfo trong client được tạo và kiểm tra quá trình giải tuần tự phản hồi của nó. So sánh đối tượng JSON dự kiến có chứa rpcId với quá trình giải tuần tự String hiện tại, sau đó xác minh rằng phương thức trả về rpcId cho phản hồi đó mà không có MismatchedInputException.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Using ThingsBoard CE 4.3.1.3 with thingsboard-client-ce 4.3.1.3, an exception occurs in the generated client method:
handleOneWayDeviceRPCRequestV2WithHttpInfo
Exception
com.fasterxml.jackson.databind.exc.MismatchedInputException:
Cannot deserialize value of type `java.lang.String` from Object value
(token `JsonToken.START_OBJECT`)
Cause
The response body is a JSON object containing the rpcId, but the client attempts to deserialize the entire response directly into a String:
String responseValue = responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<String>() {}
);
return new ApiResponse<String>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseValue
);
This fails when the API response is an object such as:
{
"rpcId": "..."
}
Proposed fix
Extract the rpcId field from the JSON response instead:
String responseValue = responseBody.isBlank()
? null
: memberVarObjectMapper.readTree(responseBody).get("rpcId").asText();
return new ApiResponse<String>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseValue
);
This correctly handles the object response and returns the rpcId as the expected String.
Expected result
handleOneWayDeviceRPCRequestV2WithHttpInfo should successfully deserialize the RPC response and return the rpcId without throwing MismatchedInputException.
- Ngôn ngữ chính
- Java
- Star
- 2
- Fork
- 2
- Merge trung bình
- 1 phút
- Pull request đã merge (30 ngày)
- 5
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Cannot differ own consent and managed consents in My Consents view and detailed consent view. Đang mở1.0.0-alpha2 Type/Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
wso2/dpdp-accelerator#272 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
infinispan/infinispan#18150 ·
-
area/frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100