From 5a133d2d707c810d4e8efd06eac669e865af072a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 8 Feb 2018 21:46:34 +0100 Subject: [PATCH] json-rpc: Return a standard compliant error when parsing fails The JSON-RPC spec specifies that if the request is unparseable we should return an error with a NULL id. This is a bit more friendly than slamming the door in the face. Signed-off-by: Christian Decker --- lightningd/jsonrpc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 55fd9d4d2..32a4a2f4b 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -660,7 +660,10 @@ again: log_unusual(jcon->ld->log, "Invalid token in json input: '%.*s'", (int)jcon->used, jcon->buffer); - return io_close(conn); + json_command_malformed( + jcon, NULL, + "Invalid token in json input"); + return io_halfclose(conn); } /* We need more. */ goto read_more;