From 8a2a6935457bf2ff5b4e511d9a034d65a6416b98 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Fri, 2 Jan 2026 15:02:35 +0100 Subject: [PATCH] fix: Parse node_discover output correctly by removing prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The .node_discover command returns prompt line before JSON array. Added parser to extract only JSON by finding first '[' character and ignoring everything before it (including 'MarWoj|* .node_discover'). Fixes JSON parsing error: 'Expecting value: line 1 column 1 (char 0)' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- app/meshcore/cli.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/meshcore/cli.py b/app/meshcore/cli.py index d817d5b..aaf3b5e 100644 --- a/app/meshcore/cli.py +++ b/app/meshcore/cli.py @@ -395,8 +395,21 @@ def node_discover() -> Tuple[bool, List[Dict]]: return False, [] try: - # Parse JSON array from stdout - nodes = json.loads(stdout) + # Clean output: remove prompt lines (e.g., "MarWoj|* .node_discover") + # and extract only the JSON array + cleaned_output = stdout.strip() + + # Find the start of JSON array (first '[') + json_start = cleaned_output.find('[') + if json_start == -1: + logger.error(f"No JSON array found in output: {stdout}") + return False, [] + + # Extract JSON from first '[' to end + json_str = cleaned_output[json_start:] + + # Parse JSON array + nodes = json.loads(json_str) if not isinstance(nodes, list): logger.error(f"node_discover returned non-array: {stdout}") return False, []