thingsboard / thingsboard/thingsboard-java-client

Incorrect JSON deserialization in `handleOneWayDeviceRPCRequestV2WithHttpInfo`

Open Beginner friendly
#74 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2
Forks
2
Avg merge
1m
Merged PRs (30d)
5

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the generated client for handleOneWayDeviceRPCRequestV2WithHttpInfo and inspect its response deserialization. Compare the expected JSON object containing rpcId with the current String deserialization, then verify that the method returns the rpcId without MismatchedInputException for that response.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.