AsamK / signal-cli

signal-cli provides an unofficial commandline, JSON-RPC and dbus interface for the Signal messenger.
GNU General Public License v3.0
3.22k stars 306 forks source link

[jsonRpc] Command returns a NullPointerException (Solved: Missing "recipient" param) #1604

Closed LunarN0v4 closed 1 month ago

LunarN0v4 commented 1 month ago

When running:

printf '{"jsonrpc":"2.0","method":"sendReceipt","id":1,"params":{"targetTimestamp":1728134498289}}' | socat UNIX-CONNECT:/run/user/1000/signal-cli/socket -

I get this as a response:

{"jsonrpc":"2.0","error":{"code":-32603,"message":"Cannot invoke \"String.startsWith(String)\" because \"identifier\" is null (NullPointerException)","data":null},"id":1}

Signal-CLI version: 0.13.7
Running on: Arch Linux (Linux 6.11.1-arch1-1)

LunarN0v4 commented 1 month ago

With -vv:

2024-10-06T19:26:29.142+1000 [daemon-listener] INFO  o.asamk.signal.jsonrpc.SocketHandler - Accepted new client connection 0:  UnixDomainPrincipal[user=nova, group=nova]
2024-10-06T19:26:29.148+1000 [receive-0] DEBUG o.a.s.manager.internal.ManagerImpl - Starting receiving messages
2024-10-06T19:26:29.148+1000 [pool-4-thread-1] TRACE o.asamk.signal.jsonrpc.JsonRpcReader - Incoming JSON-RPC message: {"jsonrpc":"2.0","method":"sendReceipt","id":1,"params":{"targetTimestamp":1728134498289}}
2024-10-06T19:26:29.152+1000 [pool-4-thread-1] TRACE o.asamk.signal.jsonrpc.JsonRpcReader - Reached end of JSON-RPC input stream.
2024-10-06T19:26:29.153+1000 [pool-5-thread-1] DEBUG o.asamk.signal.jsonrpc.JsonRpcReader - Received json rpc request, method: sendReceipt
2024-10-06T19:26:29.156+1000 [receive-0] INFO  LibSignal - [OkHttpWebSocketConnection]: [normal:570215888] connect()
2024-10-06T19:26:29.158+1000 [pool-5-thread-1] ERROR o.a.s.j.SignalJsonRpcDispatcherHandler - Command execution failed
java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "identifier" is null
        at org.asamk.signal.manager.api.RecipientIdentifier$Single.fromString(RecipientIdentifier.java:32)
        at org.asamk.signal.util.CommandUtil.getSingleRecipientIdentifier(CommandUtil.java:103)
        at org.asamk.signal.commands.SendReceiptCommand.handleCommand(SendReceiptCommand.java:41)
        at org.asamk.signal.commands.JsonRpcLocalCommand.handleCommand(JsonRpcLocalCommand.java:25)
        at org.asamk.signal.commands.JsonRpcLocalCommand.handleCommand(JsonRpcLocalCommand.java:15)
        at org.asamk.signal.jsonrpc.SignalJsonRpcCommandHandler$CommandRunnerImpl.handleCommand(SignalJsonRpcCommandHandler.java:153)
        at org.asamk.signal.jsonrpc.SignalJsonRpcCommandHandler.parseParamsAndRunCommand(SignalJsonRpcCommandHandler.java:274)
        at org.asamk.signal.jsonrpc.SignalJsonRpcCommandHandler.runCommand(SignalJsonRpcCommandHandler.java:212)
        at org.asamk.signal.jsonrpc.SignalJsonRpcCommandHandler.handleRequest(SignalJsonRpcCommandHandler.java:90)
        at org.asamk.signal.jsonrpc.SignalJsonRpcDispatcherHandler.lambda$handleConnection$4(SignalJsonRpcDispatcherHandler.java:137)
        at org.asamk.signal.jsonrpc.JsonRpcReader.handleRequest(JsonRpcReader.java:134)
        at org.asamk.signal.jsonrpc.JsonRpcReader.handleMessage(JsonRpcReader.java:85)
        at org.asamk.signal.jsonrpc.JsonRpcReader.lambda$readMessages$0(JsonRpcReader.java:72)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
2024-10-06T19:26:29.161+1000 [receive-0] INFO  LibSignal - [OkHttpWebSocketConnection]: [unidentified:2008826554] connect()
2024-10-06T19:26:29.163+1000 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Handling message actions
2024-10-06T19:26:29.163+1000 [receive-0] INFO  LibSignal - [OkHttpWebSocketConnection]: [normal:570215888] disconnect()
2024-10-06T19:26:29.164+1000 [receive-0] INFO  LibSignal - [OkHttpWebSocketConnection]: [unidentified:2008826554] disconnect()
2024-10-06T19:26:29.164+1000 [receive-0] DEBUG o.a.s.manager.internal.ManagerImpl - Finished receiving messages
2024-10-06T19:26:29.164+1000 [pool-4-thread-1] INFO  o.asamk.signal.jsonrpc.SocketHandler - Connection 0 closed:  UnixDomainPrincipal[user=nova, group=nova]
AsamK commented 1 month ago

You're missing the recipient field in the params: "recipient":"+1234567890"

LunarN0v4 commented 1 month ago

You're missing the recipient field in the params: "recipient":"+1234567890"

That seems to have fixed the problem, thank you!