Skip to content

postgres extra lacks tree-sitter-sql: --postgres on a live DB silently reports 0 nodes, exit 0 #3047

Closed

Description

@Azeem1985

What happens

Install exactly what the README prescribes for live-PostgreSQL introspection (README.md, extras table: uv tool install "graphifyy[postgres]"), then run against a real database:

graphify extract --postgres 'postgresql://postgres:[email protected]:5433/postgres'
[graphify extract] introspecting PostgreSQL schema...
[graphify extract] PostgreSQL: 0 nodes, 0 edges

Exit code 0. The database had 3 tables with FKs, a view, and a function — reproduced on postgres:17-alpine with graphifyy 0.9.48.

Why

introspect_postgres() (graphify/pg_introspect.py) reconstructs DDL and hands it to extract_sql(), which requires the tree-sitter-sql grammar. That grammar lives in the separate sql extra (pyproject.toml: sql = ["tree-sitter-sql"]) — the postgres extra ships only psycopg[binary]. When the grammar is missing, extract_sql() returns {'nodes': [], 'edges': [], 'error': 'tree_sitter_sql not installed. ...'} and introspect_postgres() returns that dict as-is; the CLI prints the node count and never looks at the error key. A live schema is indistinguishable from an empty database.

Adding tree-sitter-sql by hand makes the same command produce the full schema graph (tables/view/function nodes, FK references edges).

Suggested fix

  1. postgres = ["psycopg[binary]", "tree-sitter-sql"] — the extra should carry what its own code path needs.
  2. introspect_postgres() should raise when extract_sql() reports an error, reusing the CLI's existing (ConnectionError, ImportError) exit path, so the failure is loud instead of a plausible-looking empty graph.

PR with both fixes + a regression test to follow.

Activity

  1. Azeem1985 commented on Aug 25, 2026

    @Azeem1985
    ContributorAuthor

    Housekeeping: the PR for this is now #3072, not #3048.

    #3048 was the same two-line fix, but I had opened it from a branch that also carried our fork's other in-flight work — 62 files and 41 commits for a change that is two lines plus a test. That was unreviewable and entirely my fault. #3072 is cut from v8 and shows 4 files, +36/-1. #3048 is closed and points here.

    Nothing about the diagnosis or the fix has changed: the postgres extra is missing tree-sitter-sql, so a documented install against a live database reports 0 nodes, 0 edges and exits 0.

  2. Azeem1985 commented on Aug 25, 2026

    @Azeem1985
    ContributorAuthor

    Confirmed on the v0.9.50 tag: the postgres extra now carries tree-sitter-sql and introspect_postgres raises instead of reporting an empty graph. Thanks for the quick turnaround.

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