From 701e7c843f46c6a649203a488cece1bf19f1df90 Mon Sep 17 00:00:00 2001 From: Arek Gladki <41166437+gladkia@users.noreply.github.com> Date: Tue, 8 Sep 2026 13:26:10 +0200 Subject: [PATCH] Fix: health-check reported success after reference search failed (#1998) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `project health-check` runs three tools but only two of them can fail the check: an exception from `FindReferencingSymbolsTool` was caught and logged as a warning, while the verdict tested `find_symbol_data` alone. The command therefore printed "Health check passed - All tools working correctly" and exited 0 on a project whose reference search had just blown up - the one signal a health check exists to give. Co-authored-by: Arkadiusz Gładki --- CHANGELOG.md | 6 ++++++ src/serena/cli.py | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdd4735e..71f9bbde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ Status of the `main` branch. Changes prior to the next official version change w which could leave grandchildren as zombies; cleanup now waits for the discovered descendants (#1464) - Fix: `read_only` restriction in project definition was not applied to base tool set when in single-project context (#1938) +* CLI: + - Fix: `project health-check` reported `Health check passed - All tools working correctly` and + exited 0 even when `FindReferencingSymbolsTool` had raised, because that failure was logged as + a warning while the verdict checked `FindSymbolTool` only. A reference-search failure now fails + the check; a symbol with no references is still a pass + * Memories: - Fix: `save_memory`/`edit_memory` wrote directly to the memory file with `open(path, "w")`, which truncates it before the new content is written; a crash, OOM kill, or full disk partway through diff --git a/src/serena/cli.py b/src/serena/cli.py index 6574a9c3..a21ba757 100644 --- a/src/serena/cli.py +++ b/src/serena/cli.py @@ -1011,6 +1011,8 @@ class ProjectCommands(AutoRegisteringGroup): ) find_symbol_data = json.loads(find_symbol_result) log.info("FindSymbolTool found %d matches for symbol %s", len(find_symbol_data), symbol_name) + if not find_symbol_data: + raise ProjectCommands._HealthCheckFailure("FindSymbolTool returned no results") # Test 3: FindReferencingSymbolsTool log.info("Testing FindReferencingSymbolsTool for symbol: %s", symbol_name) @@ -1020,11 +1022,12 @@ class ProjectCommands(AutoRegisteringGroup): find_refs_data = json.loads(find_refs_result) log.info("FindReferencingSymbolsTool found %d references for symbol %s", len(find_refs_data), symbol_name) except Exception as e: - log.warning("FindReferencingSymbolsTool failed for symbol %s: %s", symbol_name, str(e)) - - # Verify tools worked as expected - if not find_symbol_data: - raise ProjectCommands._HealthCheckFailure("FindSymbolTool returned no results") + # A symbol with no references at all is a legitimate result, so the number of + # references is not asserted - but a *failure* of the reference search means the + # language server is not functional, which is the single thing this command is + # asked to determine. Logging it as a warning let the command print + # "All tools working correctly" and exit 0 after the search had already failed. + raise ProjectCommands._HealthCheckFailure(f"FindReferencingSymbolsTool failed for symbol {symbol_name}: {e}") from e log.info("Health check completed successfully")