Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def generate_refactoring_code(suggestion_id: str, repo: str | None = None)
}

async with get_session(ctx.session_factory) as session:
repository = await _get_repo(session, repo)
repository = await _get_repo(session)
row = await get_refactoring_suggestion(session, repository.id, suggestion_id)
if row is None:
return {
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/server/test_mcp_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ async def test_get_health_resolves_alias_different_from_repo_name(workspace_mcp)
assert result["kpis"]["file_count"] == 0


@pytest.mark.asyncio
async def test_generate_refactoring_code_resolves_alias_different_from_repo_name(workspace_mcp):
from repowise.server.mcp_server import generate_refactoring_code

result = await generate_refactoring_code(suggestion_id="does-not-exist", repo="frontend")

assert result["error"] is not None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding a regression test, and I confirmed that it does fail with the original LookupError when the production fix is reverted, so it genuinely guards the bug.

Could I suggest tightening the assertion to assert result["error"] == "not_found"? The tool has three different early returns that all set an error key, and only not_found proves that execution actually got past the repository lookup that this pull request fixes. In particular, llm_enrichment_enabled currently defaults to True when the repository has no configuration file, which is why the test reaches the lookup at all today. If that default were ever flipped, the tool would return error: "disabled" before touching the database, the test would still pass, and it would quietly stop testing anything.



# ---------------------------------------------------------------------------
# get_overview — workspace footer
# ---------------------------------------------------------------------------
Expand Down
Loading