Skip to content

Surface tree-sitter version-mismatch hint instead of bare TypeError#671

Closed
azizur100389 wants to merge 1 commit into
Graphify-Labs:v6from
azizur100389:fix/tree-sitter-version-error-msg
Closed

Surface tree-sitter version-mismatch hint instead of bare TypeError#671
azizur100389 wants to merge 1 commit into
Graphify-Labs:v6from
azizur100389:fix/tree-sitter-version-error-msg

Conversation

@azizur100389

Copy link
Copy Markdown
Contributor

Summary

When a user has an older tree-sitter paired with a newer language binding (or vice versa), Language() raises TypeError with messages like "missing 1 required positional argument: 'name'". The current catch-all except Exception in _extract_generic() stores that bare message in the per-file error field, leaving users no actionable signal.

Add a dedicated TypeError branch that returns the upgrade hint:

tree-sitter version mismatch for tree_sitter_python: missing 1 required positional argument: 'name'. Try: pip install --upgrade tree-sitter tree-sitter-languages

Behavior is unchanged for all non-version-mismatch errors — the broader Exception handler still runs.

This PR replaces the old #96 (which targeted stale v3 and bundled three changes). The other two changes from #96 are no longer needed:

  • Progress logging — already implemented in v6 (parallel/sequential extraction emit it).
  • HTML sampling — overlaps with v6's GRAPHIFY_VIZ_NODE_LIMIT env-var approach, so leaving v6's design as-is.

Test plan

  • New tests/test_extract.py::test_extract_generic_surfaces_tree_sitter_version_mismatch_hint — uses monkeypatch.setitem(sys.modules, ...) to inject a fake tree_sitter whose Language() raises TypeError, then asserts the returned error contains both "tree-sitter version mismatch" and "pip install --upgrade".
  • All existing tests still pass; no behavior change for any path that doesn't hit TypeError.

When a user has an older tree-sitter installed against a newer language
binding (or vice versa), Language() raises TypeError with messages like
"missing 1 required positional argument: 'name'". The previous catch-all
Exception handler stored that bare message in the per-file error field,
giving users no actionable signal.

Add a dedicated TypeError branch in _extract_generic() that returns a
clearer error with the upgrade command:

  tree-sitter version mismatch for tree_sitter_python: ... .
  Try: pip install --upgrade tree-sitter tree-sitter-languages

Behavior is unchanged for all non-version-mismatch errors - the broader
Exception handler still runs as before.
@safishamsi

Copy link
Copy Markdown
Collaborator

Merged via PR #671. Shipped in v0.7.8.

@safishamsi safishamsi closed this May 7, 2026
hypnwtykvmpr pushed a commit to hypnwtykvmpr/vampyre that referenced this pull request May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants