Skip to content

[Bug] Fuzzy search in find_code returns no results for close matches #758

Description

@qwertist

Description

codegraph_find_code with fuzzy_search=true and edit_distance=2 returns zero results for queries that differ by just 1 character from an existing function name.

Steps to Reproduce

pip install codegraphcontext==0.3.1
cgc index /path/to/project  # project contains a function named "myFunction"

Then via MCP:

# Exact search works:
codegraph_find_code(query="myFunction")
# → returns myFunction correctly

# Fuzzy search fails:
codegraph_find_code(query="myFuncton", fuzzy_search=true, edit_distance=2)
# → returns 0 results

Expected Behavior

Fuzzy search with edit_distance=2 should find myFunction when querying myFuncton (edit distance = 1, well within threshold).

Actual Behavior

{
  "query": "myfuncton",
  "functions_by_name": [],
  "classes_by_name": [],
  "variables_by_name": [],
  "content_matches": [],
  "ranked_results": [],
  "total_matches": 0
}

Note: the query is lowercased to myfuncton in the response, suggesting the fuzzy search may be operating on a lowercased version while the index stores original case — potentially causing the mismatch.

Environment

  • codegraphcontext: 0.3.1
  • Database backend: KùzuDB (default)
  • Python: 3.12.3
  • OS: Linux (Ubuntu)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions