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")