From 82cd0e5c9d2756615435a2782838500b3a2b8c96 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Mon, 2 Feb 2026 15:58:20 -0700 Subject: [PATCH] Fix Response.data normalisation in parse_message() too The previous commit only fixed Response.from_json(), but the serial client's read loop uses parse_message() which constructs Response directly. Apply the same string-to-dict normalisation there. --- src/mcbluetooth_esp32/protocol.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mcbluetooth_esp32/protocol.py b/src/mcbluetooth_esp32/protocol.py index 1e911d2..f51deb1 100644 --- a/src/mcbluetooth_esp32/protocol.py +++ b/src/mcbluetooth_esp32/protocol.py @@ -207,11 +207,14 @@ def parse_message(line: str) -> Command | Response | Event: ) if msg_type == MsgType.RESP: + raw_data = obj.get("data", {}) + if isinstance(raw_data, str): + raw_data = {"error": raw_data} return Response( type=MsgType.RESP, id=obj["id"], status=Status(obj["status"]), - data=obj.get("data", {}), + data=raw_data if isinstance(raw_data, dict) else {}, ) if msg_type == MsgType.EVENT: