Skip to content

[Bug] analysis_tools.py passes str to _validate_repo_root() which expects Path — all 5 analysis tools broken #384

@YutenC

Description

@YutenC

Bug Description

All 5 functions in analysis_tools.py crash with 'str' object has no attribute 'resolve' because they pass a raw str to _validate_repo_root(), which expects a Path object.

When repo_root is omitted (defaults to ""), the error becomes 'NoneType' object has no attribute 'resolve' — there's no fallback to find_project_root().

Affected Tools

  • get_hub_nodes_func
  • get_bridge_nodes_func
  • get_knowledge_gaps_func
  • get_surprising_connections_func
  • get_suggested_questions_func

Version

code-review-graph 2.3.2
Python 3.12

Steps to Reproduce

Via MCP:

{ "tool": "get_hub_nodes_tool", "arguments": { "repo_root": "/path/to/repo", "top_n": 10 } }

Or:

{ "tool": "get_knowledge_gaps_tool", "arguments": {} }

Both fail. The first with 'str' object has no attribute 'resolve', the second with empty string also failing.

Root Cause

In tools/analysis_tools.py (all 5 functions):

# BUG — repo_root is str, _validate_repo_root expects Path
root = _validate_repo_root(repo_root)
store = _get_store(str(root))

Compare with the correct pattern in tools/_common.py (_get_store) and tools/refactor_tools.py:

# CORRECT — wraps in Path() and handles empty/None fallback
root = _validate_repo_root(Path(repo_root)) if repo_root else find_project_root()

_validate_repo_root is defined as:

def _validate_repo_root(path: Path) -> Path:
    resolved = path.resolve()  # <-- str has no .resolve()

Suggested Fix

In tools/analysis_tools.py, change all 5 occurrences from:

root = _validate_repo_root(repo_root)
store = _get_store(str(root))

To:

root = _validate_repo_root(Path(repo_root)) if repo_root else find_project_root()
store = _get_store(str(root))

Or, simplify by just using _get_store() directly (which already handles the conversion):

store, root = _get_store(repo_root or None)

This is a one-line fix per function (5 lines total).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions