Skip to content

R (.r/.R) listed in CODE_EXTENSIONS but has no AST extractor — silently drops all R files with zero warning #1689

Open

Description

@Sneakypeat

Summary

.r/.R is included in detect.py's CODE_EXTENSIONS set, so R files are classified as FileType.CODE and counted in the scan summary (e.g. found 24 code, ...). But extract.py's _DISPATCH dict — the table that maps extensions to an actual AST extractor function — has no .r/.R entry at all (it covers ~45 languages: Python, JS/TS, Go, Rust, Java, Ruby, C/C++, Swift, Kotlin, Scala, PHP, Lua, Zig, PowerShell, Elixir, Objective-C, Julia, Fortran, Vue, Svelte, Astro, Dart, Verilog, SQL, Pascal/Delphi, DragonFly BASIC, .NET project files, etc. — but not R).

Reproduction

Run graphify extract . on a project that's mostly .R scripts (e.g. an R/renv analysis project with ~17 .R files and a handful of .py helper scripts).

  • Scan step reports something like found 24 code, 0 docs, 1 papers, 0 images — the R files are counted as code.
  • AST extraction runs on all 24 "code" files.
  • The resulting graph.json only contains nodes/edges from the non-R files (in my case, 7 small Python scripts). All ~17 .R files contribute zero nodes and zero edges.
  • No warning, error, or log line indicates this. The CLI reports success (wrote graph.json: N nodes, M edges, K communities) as if the whole codebase was mapped.

Root cause

In extract.py:

def _get_extractor(path):
    ...
    return _DISPATCH.get(path.suffix)

For a .R file, _DISPATCH.get(".R") returns None (no key for .r or .R). The caller handles this by silently returning an empty result:

extractor = _get_extractor(path)
if extractor is None:
    return idx, {"nodes": [], "edges": []}

Meanwhile detect.py::classify_file lowercases the extension before checking CODE_EXTENSIONS (ext = path.suffix.lower()), so .R files do get classified as FileType.CODE and counted in scan stats — creating a mismatch between "files graphify says it found as code" and "files graphify can actually parse."

Impact

For any primarily-R codebase, graphify extract silently produces a graph that reflects none of the actual project code, with no indication to the user that anything was skipped. This is worse than an explicit "unsupported language" error, because the tool reports success and the user has no reason to suspect the graph is incomplete/misleading.

Suggested fix

Either:

  1. Add a real .r/.R extractor (tree-sitter has an R grammar — tree-sitter-r), consistent with how other languages are wired into _DISPATCH; or
  2. At minimum, when _get_extractor() returns None for a file that classify_file() counted as FileType.CODE, surface a warning (e.g. [graphify extract] WARNING: N code files have no AST extractor and were skipped: .R (17), ...) instead of silently returning empty results and reporting overall success.

Option 2 alone would have saved a lot of confused debugging — the CLI output gave no signal that anything was wrong.

Activity

  1. safishamsi commented on Jul 6, 2026

    @safishamsi
    Member

    Fixed on v8 (377dc7f), shipping in the next release — went with your option 2 (surface it) for now.

    You were exactly right about the mismatch: .r/.R (also .ejs, .ets) are in CODE_EXTENSIONS so they're classified as code and counted, but there's no dispatch entry, so _get_extractor returns None and the file contributes zero nodes. The #1666 zero-node warning couldn't catch these because it only fires when an extractor exists.

    extract() now emits, grouped by extension:

    warning: 17 file(s) are classified as code but graphify has no AST extractor for their language, so they contributed nothing to the graph: .r (17). Please open an issue to request support for these (#1689).
    

    It fires only for files actually present with no extractor (today that's just .ejs, .ets, .r), so a primarily-R corpus no longer reports success as if it were mapped. Regression tests cover the warning and the no-warning case.

    Adding a real tree-sitter-r extractor (your option 1) is the natural follow-up and I'll leave this issue's spirit tracked for that; the silent-data-loss part is resolved now. Thanks for the precise root-cause.

  2. fxi commented on Jul 15, 2026

    @fxi

    Native tree-sitter-r support would be nice. Currently working on a Legacy R Shiny app migration, and the struggle is real

  3. added a commit that references this issue on Jul 15, 2026
    f3acf2d
  4. tihh07 commented on Jul 27, 2026

    @tihh07

    Still reproducing on 0.9.22, and I want to add a data point about how much this silently removes, plus a note on #2116.

    Concrete case

    A private analytics repo whose core is an R pipeline (43 .R files, ~120 files total, mixed R / SQL / Markdown).

    .R files on disk 43
    AST nodes produced by them 0
    AST nodes in the whole graph 27 (.sql 12, .ts 8, .py 3, .ps1 2, extensionless 2)
    Semantic (LLM) nodes 704 of 731

    The cascade is what makes it costly, and it is worth spelling out because each step is individually reasonable:

    1. .r is in CODE_EXTENSIONS and analyze.py maps it to language r, so the file is counted as code;
    2. code files take the AST path only — and there is no R dispatch, so they yield nothing;
    3. because they are typed as code, they are also never queued for semantic extraction (that queue is document / paper / image).

    So R files fall between the two extractors rather than being handled by either. Exit code is 0.

    The only R content that reached my graph got there indirectly: 119 nodes whose source_file points at .R paths, wired together by 86 calls edges with both ends inside that set — but every one of those nodes has source_location: null and _origin unset — LLM nodes attributed to R files while reading the project's Markdown, not parser output. They cover 22 of 43 files; the other 21 have no node at all, including the pipeline's top-level orchestrator and an entire 5-script chain that writes to Postgres.

    That is the failure mode worth highlighting: the graph does not look empty on R. It looks populated, with plausible function names and call edges, so a consumer has no signal that half the corpus is missing and that none of it is anchored to a line. The #1689 warning on stderr is the only thing standing between that graph and a wrong conclusion — which is why I would argue it should be surfaced in GRAPH_REPORT.md too, not just stderr, for as long as the gap exists.

    #2116 looks closed in error

    #2116 ("Feature Request: Native Tree-sitter Support for R", where the author offered to contribute the extractor) was closed as COMPLETED on 2026-07-22 — but nothing appears to have shipped:

    • 0.9.27 (latest, released 2026-07-26) has no tree-sitter-r in pyproject.toml;
    • there is no graphify/extractors/r.py on main;
    • pip install "graphifyy[all]" pulls no R grammar — there is no r extra.

    If that close was a mistake, reopening it would also stop the next person from concluding, as I nearly did, that upgrading fixes this.

    Happy to test a branch against the repo above if an extractor lands — the R here is ordinary CRAN-style code (<- function(), pkg::fun, source()), so it is a fair smoke test.

  5. juliethsantamaria commented on Aug 9, 2026

    @juliethsantamaria

    Hi! I'm an economist using Graphify to build a knowledge graph for
    research projects.

    Request: Add R and Stata Language Support

    I work extensively with both R and Stata
    (statistical analysis and econometric modeling), and both are currently silently dropped from the graph with no warning.

    R Support

    Good news: Tree-sitter already has a mature, actively maintained
    R grammar maintained by the R-lib team (Posit/RStudio):

    Integration should be straightforward given the existing grammar.

    Stata Support

    Also good news: A production-quality tree-sitter-stata grammar
    already exists and is actively maintained by Jonathan Bearak:

    Rather than building from scratch, Graphify could integrate or adapt
    the existing grammar.

    Why This Matters

    • R/Stata are the standard in academic economics, policy analysis,
      and quantitative social science
    • Graphify support would enable true knowledge graphs for research
      projects combining code, papers, data, and analysis scripts
    • Similar demand from researchers as Python/Julia communities

    What I Can Provide

    I'm happy to support implementation by providing:

    1. Test cases and feedback on the extracted graph quality
    2. Suggestions on what econometric analysis constructs should be
      prioritized for extraction (function definitions, program calls,
      variable operations, etc.)

    Summary

    Both R and Stata already have working tree-sitter grammars. The
    integration work is the remaining piece. This would unblock
    economists and other quantitative researchers from using Graphify
    for reproducible research.

  6. bastienchassagnol commented on Aug 23, 2026

    @bastienchassagnol

    +1 from the DeCovarT R package (bastienchassagnol/DeCovarT) — bulk RNA-seq deconvolution with a sizeable exported API under R/ (numeric-prefixed modules, tests mirroring stems, scripts + Quarto vignettes).

    We are trying graphify as a local knowledge graph in Cursor. On v0.9.48, --code-only reports our .R files as code but they contribute zero nodes (the warning about missing extractors helped; thanks for surfacing that). The graph is otherwise dominated by vendored JS under slides/_extensions/ until we trim via .graphifyignore.

    An R/tree-sitter-r extractor would materially help R package authors: map @export entry points, @inheritParams chains, testthat coverage of R/03_03_*.R, and call paths into optimisation helpers — the sort of cross-file structure grep alone misses. Option (2) (explicit skip warnings) is already a big UX win; option (1) would make graphify genuinely useful for CRAN/Bioc-style repos like ours.

    Happy to retest on a build that adds .R support.

  7. LarryCalvert commented on Aug 24, 2026

    @LarryCalvert

    Confirming this is still present as of graphify 0.9.48. One update: it no longer fails silently — I get an explicit warning now (X file(s)... no AST extractor for their language: .r (N)), so that part seems to have been addressed. But the R files still contribute zero nodes to the graph.

    Also worth noting: the v0.6.2 changelog lists "R language (.r) support via LLM semantic extraction" as a shipped feature. That fallback doesn't appear to be happening either — my .r files weren't included in the semantic-extraction batch, only my docs/PDFs/images were. So it looks like R support regressed from a working (semantic-pass) state in v0.6.2 to a fully-dropped state now, rather than never having existed.

  8. omsenjalia commented on Oct 18, 2026

    @omsenjalia
    Contributor

    This looks fixed on the v8 branch by commits d68d6012 (feat: add R language extractor), 377dc7f3 (fix(extract): warn when code files have no AST extractor instead of silently dropping them (#1689)). Could a maintainer confirm and close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions