Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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.

Valutazione

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

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.

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.

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

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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.

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.