diff --git a/CHANGES b/CHANGES index 8f523e6927..dd0e70e345 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,16 @@ +8.0.0-dev.447 | 2025-06-22 15:49:11 +0200 + + * GH-4594: Align WebSocket error in cluster with one in Broker (Benjamin Bannier, Corelight) + + The schema of cluster WebSocket error messages deviated from the + existing one in Broker which breaks seamless migration from the Broker + WebSocket bindings. + + This patch aligns the serialization in cluster with the one in Broker. + This is technically a breaking change of the cluster schema, but since + it never worked like documented and is still experimental this is + probably fine. + 8.0.0-dev.445 | 2025-06-22 15:48:21 +0200 * GH-4571: broker: Handle Broker::publish() with non Broker::Event (Arne Welzel, Corelight) diff --git a/VERSION b/VERSION index 54d53db5dd..67aaef6c49 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.0-dev.445 +8.0.0-dev.447 diff --git a/src/cluster/websocket/WebSocket.cc b/src/cluster/websocket/WebSocket.cc index d9797aa0ed..e66f0854b2 100644 --- a/src/cluster/websocket/WebSocket.cc +++ b/src/cluster/websocket/WebSocket.cc @@ -144,7 +144,7 @@ WebSocketClient::SendInfo WebSocketClient::SendError(std::string_view tag, std:: *out++ = ','; broker::format::json::v1::append_field("code", tag, out); *out++ = ','; - broker::format::json::v1::append_field("message", message, out); + broker::format::json::v1::append_field("context", message, out); *out++ = '}'; return SendText(buf); } diff --git a/testing/btest/Baseline/cluster.websocket.bad-event-args/..client.out b/testing/btest/Baseline/cluster.websocket.bad-event-args/..client.out index f9e01b1fea..a325fb3fae 100644 --- a/testing/btest/Baseline/cluster.websocket.bad-event-args/..client.out +++ b/testing/btest/Baseline/cluster.websocket.bad-event-args/..client.out @@ -1,7 +1,7 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. Connected! -err1 {'type': 'error', 'code': 'deserialization_failed', 'message': 'failed to decode JSON object'} -err2 {'type': 'error', 'code': 'deserialization_failed', 'message': 'failed to create Zeek event'} -err3 {'type': 'error', 'code': 'deserialization_failed', 'message': 'failed to create Zeek event'} +err1 {'type': 'error', 'code': 'deserialization_failed', 'context': 'failed to decode JSON object'} +err2 {'type': 'error', 'code': 'deserialization_failed', 'context': 'failed to create Zeek event'} +err3 {'type': 'error', 'code': 'deserialization_failed', 'context': 'failed to create Zeek event'} pong {'@data-type': 'string', 'data': 'pong'} {'@data-type': 'vector', 'data': [{'@data-type': 'string', 'data': 'Hello'}, {'@data-type': 'count', 'data': 42}]} -err4 {'type': 'error', 'code': 'deserialization_failed', 'message': 'failed to decode JSON object'} +err4 {'type': 'error', 'code': 'deserialization_failed', 'context': 'failed to decode JSON object'} diff --git a/testing/btest/Baseline/cluster.websocket.bad-subscriptions/..client.out b/testing/btest/Baseline/cluster.websocket.bad-subscriptions/..client.out index 228c6687c9..223dec6314 100644 --- a/testing/btest/Baseline/cluster.websocket.bad-subscriptions/..client.out +++ b/testing/btest/Baseline/cluster.websocket.bad-subscriptions/..client.out @@ -1,5 +1,5 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -broken array response {'type': 'error', 'code': 'deserialization_failed', 'message': 'subscriptions not an array'} -non string error {'type': 'error', 'code': 'deserialization_failed', 'message': 'individual subscription not a string'} -mix error {'type': 'error', 'code': 'deserialization_failed', 'message': 'individual subscription not a string'} +broken array response {'type': 'error', 'code': 'deserialization_failed', 'context': 'subscriptions not an array'} +non string error {'type': 'error', 'code': 'deserialization_failed', 'context': 'individual subscription not a string'} +mix error {'type': 'error', 'code': 'deserialization_failed', 'context': 'individual subscription not a string'} ack True diff --git a/testing/btest/Baseline/cluster.websocket.bad-url/..client.out b/testing/btest/Baseline/cluster.websocket.bad-url/..client.out index 360a9982a2..a168cba450 100644 --- a/testing/btest/Baseline/cluster.websocket.bad-url/..client.out +++ b/testing/btest/Baseline/cluster.websocket.bad-url/..client.out @@ -1,4 +1,4 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. Connected ws_good! Connected ws_bad! -Error for ws_bad {'type': 'error', 'code': 'invalid_uri', 'message': 'Invalid URI - use /v1/messages/json'} +Error for ws_bad {'type': 'error', 'code': 'invalid_uri', 'context': 'Invalid URI - use /v1/messages/json'}