Skip to content

analysis_tools.py: 5 functions fail with "'str' object has no attribute 'resolve'" #408

@SHFOO13

Description

@SHFOO13

Bug

In code_review_graph/tools/analysis_tools.py (v2.3.2), five tool functions fail with:

'str' object has no attribute 'resolve'

Affected tools:

  • get_hub_nodes_func (line 31-32)
  • get_bridge_nodes_func (line 59-60)
  • get_knowledge_gaps_func (line 85-86)
  • get_surprising_connections_func (line 121-122)
  • get_suggested_questions_func (line 147-148)

Root cause

Each affected function does:

root = _validate_repo_root(repo_root)   # repo_root is a str
store = _get_store(str(root))

But _validate_repo_root (in tools/_common.py) is typed as accepting a Path:

def _validate_repo_root(path: Path) -> Path:
    resolved = path.resolve()   # AttributeError when called with str

The MCP tool signature passes repo_root as a str (the function's own type hint). Calling .resolve() on a string raises AttributeError.

A second issue: _get_store returns a tuple[GraphStore, Path], but the result is assigned to store as if it were a single GraphStore. Subsequent calls like find_hub_nodes(store, top_n=top_n) would receive the whole tuple.

Working pattern (used by all other tool modules)

tools/query.py and other working modules use this single line:

store, root = _get_store(repo_root)

_get_store already wraps repo_root in Path() before validating, and returns the tuple (GraphStore, Path).

Fix

In analysis_tools.py, replace every occurrence of:

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

with:

store, root = _get_store(repo_root)

This fixes all 5 functions and matches the pattern used elsewhere in the package.

Reproduction

Any MCP client invoking mcp__code-review-graph__get_hub_nodes_tool (or any of the other 4 affected tools) hits the error immediately.

Environment

  • Package: code-review-graph==2.3.2
  • Python: 3.10
  • Installed via: uvx code-review-graph serve

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