Repository navigation
Description
Summary
graphify update . crashes during AST extraction on every .ts/.tsx/.js file with IndexError: tuple index out of range when the project's pnpm-workspace.yaml lists the repo root as a package (packages: - '.'). This is valid pnpm config (single-package-at-root workspace), but it produces a Path.glob('.') call, which raises IndexError on Python 3.10.
Result: 0 nodes extracted, build aborts with Rebuild failed: tuple index out of range. The failure is uniform across all files, so it looks like a parser/tree-sitter problem — but it isn't.
Environment
- graphify (
graphifyy) 0.8.25 - Python 3.10.18
- Platform: macOS 15.7.4 (arm64)
Repro
- In any JS/TS project, create a
pnpm-workspace.yaml:packages: - '.' - 'examples/*'
- Have at least one
.tsfile with animportstatement (triggers the workspace resolver). - Run
graphify update .
Every file is skipped:
warning: skipped /…/src/nav/appCatalog.ts (IndexError: tuple index out of range)
…
Nothing to update or rebuild failed — check output above.
[graphify watch] Rebuild failed: tuple index out of range
Root cause
The traceback (normally swallowed by the broad except in extract_js):
File ".../graphify/extract.py", line 2229, in walk
config.import_handler(node, source, file_nid, stem, edges, str_path)
File ".../graphify/extract.py", line 1238, in _import_js
resolved = _resolve_js_import_target(raw, str_path)
File ".../graphify/extract.py", line 1213, in _resolve_js_import_target
resolved_path = _resolve_js_module_path(raw, Path(str_path).parent)
File ".../graphify/extract.py", line 396, in _resolve_js_module_path
return _resolve_workspace_import(raw, start_dir)
File ".../graphify/extract.py", line 360, in _resolve_workspace_import
packages = _load_workspace_packages(start_dir)
File ".../graphify/extract.py", line 310, in _load_workspace_packages
for package_dir in root.glob(pattern):
File ".../python3.10/pathlib.py", line 1033, in glob
selector = _make_selector(tuple(pattern_parts), self._flavour)
File ".../python3.10/pathlib.py", line 369, in _make_selector
pat = pattern_parts[0]
IndexError: tuple index out of range
_workspace_globs correctly returns '.' as a package glob, but _load_workspace_packages then calls root.glob('.'). On Python 3.10, Path.glob('.') has empty pattern_parts and raises IndexError (Python 3.11+ raises a clearer error / behaves differently, but . is never a meaningful glob — it just means "this directory").
Suggested fix
In _load_workspace_packages (extract.py ~line 309), treat ././ as the workspace root itself instead of globbing:
packages: dict[str, Path] = {}
for pattern in _workspace_globs(root / "pnpm-workspace.yaml"):
package_dirs = [root] if pattern in (".", "./") else root.glob(pattern)
for package_dir in package_dirs:
...This resolves the root package correctly and avoids the empty-glob crash. Verified locally against 0.8.25 — full extraction (276 files, 1692 nodes) succeeds with this one-line guard.
(Possible secondary hardening: extract_js swallows the real traceback and only surfaces IndexError: tuple index out of range, which made this look like a tree-sitter grammar/version issue. Logging the failing frame, or at least the resolver context, at a higher verbosity would shorten diagnosis.)
Activity
safishamsi commentedon May 30, 2026
Fixed in commit d4e1d4b.
Root cause confirmed:
_load_workspace_packages(extract.py:310) calledroot.glob('.')whenpnpm-workspace.yamlhaspackages: - '.'. On Python 3.10,Path.glob('.')hits emptypattern_partsand raisesIndexError— which then propagated through every JS/TS import resolution, causing every file to be skipped uniformly.Your one-line guard was exactly right:
Also added
GRAPHIFY_DEBUG=1env var support in_safe_extractso future crashes print the full traceback rather than just the exception message — good call on flagging that diagnostic gap. Plus a regression test for this exact case. Thanks for the precise repro and proposed fix.fix pnpm-workspace.yaml packages:'.' crash on Python 3.10 (closes Gra…
fix pnpm-workspace.yaml packages:'.' crash on Python 3.10 (closes Gra…