thingsboard / thingsboard/thingsboard-java-client

Incorrect JSON deserialization in `handleOneWayDeviceRPCRequestV2WithHttpInfo`

Aperta Adatta ai principianti
#74 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
2
Fork
2
Merge medio
1m
PR unite (30g)
5

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Cerca handleOneWayDeviceRPCRequestV2WithHttpInfo nel client generato e ispeziona la deserializzazione della sua risposta. Confronta l’oggetto JSON previsto contenente rpcId con l’attuale deserializzazione come String, quindi verifica che il metodo restituisca rpcId per quella risposta senza MismatchedInputException.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
74/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.