Skip to content

fix(extract): warn when files are skipped due to a missing optional dependency (#1745)#1750

Open
rithyKabir wants to merge 1 commit into
Graphify-Labs:v8from
rithyKabir:fix/1745-surface-missing-sql-extra
Open

fix(extract): warn when files are skipped due to a missing optional dependency (#1745)#1750
rithyKabir wants to merge 1 commit into
Graphify-Labs:v8from
rithyKabir:fix/1745-surface-missing-sql-extra

Conversation

@rithyKabir

Copy link
Copy Markdown

Fixes #1745.

Problem

When the [sql] extra isn't installed, extract_sql returns an "error" result for every .sql file — and nothing consumes it. Both existing safety nets deliberately miss this case:

So the graph builds "successfully" while the entire SQL schema silently contributes nothing. The same mechanism affects the other optional grammars that hard-fail on import: .tf/.tfvars/.hcl ([terraform]) and .dm/.dme ([dm]). Pascal is unaffected — it falls back to its regex extractor.

Fix

extract() now surfaces these files right after the #1689 block, grouped by extension, naming the extra that restores the language:

warning: 2 .sql file(s) contributed nothing to the graph because a dependency is missing: tree_sitter_sql not installed. Install it with: pip install "graphifyy[sql]" (#1745)

A new _EXTRA_FOR_EXTENSION map lives next to _DISPATCH so the two stay in sight of each other. For a missing core grammar (broken env), the extension isn't in the map and the extractor's own error is printed verbatim with no extra hint.

Tests

Mirrors the #1689 regression tests: one simulates the missing dependency (monkeypatch.setitem(sys.modules, "tree_sitter_sql", None)) and asserts the warning fires while a sibling .py file still extracts normally; one asserts no warning when the extra is installed. Full tests/test_extract.py passes (117/117), ruff clean.

🤖 Generated with Claude Code

…ependency (Graphify-Labs#1745)

.sql files (and .tf/.hcl/.dm) have a dispatch entry, so the Graphify-Labs#1689
no-extractor warning can't fire; their extractors return an "error"
result when the grammar package is absent, so the Graphify-Labs#1666 zero-node
warning skips them too. The graph then builds "successfully" while
every such file silently contributes nothing.

extract() now surfaces these files grouped by extension, naming the
optional-dependency extra that restores the language:

  warning: 2 .sql file(s) contributed nothing to the graph because a
  dependency is missing: tree_sitter_sql not installed. Install it
  with: pip install "graphifyy[sql]" (Graphify-Labs#1745)

Regression tests cover the warning (via a simulated missing
tree_sitter_sql) and the no-warning case when the extra is installed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

.sql files silently extract 0 nodes when the [sql] extra is missing

1 participant