Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(server): treat a missing repository as no index in change-risk health references (#2553)
Raghav Chamadiyad0da7906cb16
diff --git a/packages/server/src/repowise/server/mcp_server/tool_change_risk.py b/packages/server/src/repowise/server/mcp_server/tool_change_risk.pyindex 1e695e039..671c9e9d8 100644--- a/packages/server/src/repowise/server/mcp_server/tool_change_risk.py+++ b/packages/server/src/repowise/server/mcp_server/tool_change_risk.py@@ -363,7 +363,8 @@ async def _attach_health_references(ctx: Any, delta: Any) -> None:.scalars().all())- except SQLAlchemyError:+ except (LookupError, SQLAlchemyError):+ # No repository row is "no index", as in the sibling enrichments.returnif not rows:returndiff --git a/tests/unit/server/mcp/test_change_risk.py b/tests/unit/server/mcp/test_change_risk.pyindex e84a56646..e0701b6b4 100644--- a/tests/unit/server/mcp/test_change_risk.py+++ b/tests/unit/server/mcp/test_change_risk.py@@ -425,3 +425,22 @@ def test_score_measures_names_only_the_supporting_diff_shape_signal() -> None:assert "diff size and spread" in SCORE_MEASURESassert "where the change lands" in SCORE_MEASURESassert "probability" not in SCORE_MEASURES+++async def test_health_references_on_an_index_without_a_repository_are_skipped(factory) -> None:+ """An index with no repository row reads as "no index", not a failed call."""+ from repowise.server.mcp_server import tool_change_risk as tool++ finding = SimpleNamespace(+ path="a.py",+ biomarker_type="complex_method",+ symbol="f",+ line_start=1,+ line_end=2,+ health_reference=None,+ )+ await tool._attach_health_references(+ SimpleNamespace(session_factory=factory), SimpleNamespace(findings=[finding])+ )+ assert finding.health_reference is None