Turasa / libsignal-service-java

GNU General Public License v3.0
37 stars 21 forks source link

Nullpointer exception when calling SignalServiceMessageReceiver.retrieveMessages(..) due to updatedPni field #32

Open jimhh opened 1 year ago

jimhh commented 1 year ago

I get a Null Pointer Exception when receiving messages, and thus cannot receive any messages.

It happens under SignalServiceMessageReceiver.retrieveMessages(..) when the received envelope has null for entity.getUpdatedPni(). When this is null the Envelop.Builder will fail when calling .setUpdatedPni(updatedPni) since for some reason it is using the String value to make the call value.getClass(). I would guess this is generated code based on the protobuf stuff. So, a non-null check would be needed before this, unless the problem lies elsewhere.

I can't really say why it is null. I send a message from my phone and receive it with my bot. Perhaps the deserialization is incorrectly configured to interpret missing data as null, the field is optional.

optional string updatedPni = 15;

The signal-client "lib" code in the adroid app does not set the updatedPni argument

envelope = new SignalServiceEnvelope(entity.getType(),
                                             Optional.of(address),
                                             entity.getSourceDevice(),
                                             entity.getTimestamp(),
                                             entity.getContent(),
                                             entity.getServerTimestamp(),
                                             messageResult.getServerDeliveredTimestamp(),
                                             entity.getServerUuid(),
                                             entity.getDestinationUuid(),
                                             entity.isUrgent(),
                                             entity.isStory());

I may have done something wrong, however I can't see what that would be.

AsamK commented 1 year ago

Signal-Android doesn't use this forked library and the updatedPni field is an addition here. You could check the signal-cli code if that does something differently: https://github.com/AsamK/signal-cli/