Incorrect JSON deserialization in `handleOneWayDeviceRPCRequestV2WithHttpInfo`

Đang mở Phù hợp với người mới
#74 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
java
Lĩnh vực
api

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.