From d853c1fad4133954808cfb8957f0f54e60062864 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sat, 3 Jan 2026 14:23:58 +0100 Subject: [PATCH] debug: Add detailed logging for .contacts command diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Log success status, stdout/stderr lengths - Preview stdout content (first 500 chars) - Check for empty output before JSON parsing - Log problematic JSON if parsing fails This will help diagnose why .contacts returns empty output through bridge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- app/meshcore/cli.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/meshcore/cli.py b/app/meshcore/cli.py index 2cd7677..4892ac0 100644 --- a/app/meshcore/cli.py +++ b/app/meshcore/cli.py @@ -654,10 +654,20 @@ def get_contacts_json() -> Tuple[bool, Dict[str, Dict], str]: try: success, stdout, stderr = _run_command(['.contacts']) + # Debug logging to diagnose empty output + logger.info(f".contacts result: success={success}, stdout_len={len(stdout)}, stderr_len={len(stderr)}") + logger.debug(f".contacts stdout preview (first 500 chars): {stdout[:500] if stdout else 'EMPTY'}") + logger.debug(f".contacts stderr: {stderr if stderr else 'EMPTY'}") + if not success: logger.error(f".contacts command failed: {stderr}") return False, {}, stderr or 'Failed to execute .contacts command' + # Check if stdout is empty + if not stdout or not stdout.strip(): + logger.error(f".contacts returned empty output (success={success})") + return False, {}, '.contacts command returned empty output' + # Parse JSON output # The output is a single JSON object with public_keys as keys try: @@ -666,6 +676,7 @@ def get_contacts_json() -> Tuple[bool, Dict[str, Dict], str]: return True, contacts_dict, "" except json.JSONDecodeError as e: logger.error(f"Failed to parse .contacts JSON output: {e}") + logger.debug(f"Problematic JSON string (first 1000 chars): {stdout[:1000]}") return False, {}, f'JSON parse error: {e}' except Exception as e: