Skip to content

fix: studio crashes when user lacks privileges on some schemas#5618

Open
xiekw2010 wants to merge 1 commit intodrizzle-team:betafrom
xiekw2010:fix/studio-skip-identity-missing-metadata
Open

fix: studio crashes when user lacks privileges on some schemas#5618
xiekw2010 wants to merge 1 commit intodrizzle-team:betafrom
xiekw2010:fix/studio-skip-identity-missing-metadata

Conversation

@xiekw2010
Copy link
Copy Markdown

Summary

  • Problem: Drizzle Studio crashes with Identity realtime.subscription.id columns missing metadata: null when the database user only has access to specific schemas (e.g. multi-tenant setups with schema-level isolation, or Supabase with restricted roles). The Studio frontend introspects all visible schemas including ones the user cannot fully read, causing a fatal error.

  • Fix 1 — Graceful handling of missing metadata: Changed throw to console.warn + continue in introspect functions (postgres/introspect.ts, postgres/aws-introspect.ts, cockroach/introspect.ts) when identity or generated column metadata is null, so a single inaccessible column doesn't crash the entire introspection.

  • Fix 2 — Studio respects schemaFilter: Passed the schemaFilter config from drizzle.config.ts through to the Studio proxy server. The proxy now filters pg_namespace query results so the Studio frontend only sees schemas the user has configured, preventing it from attempting to introspect schemas the user lacks privileges on.

How to reproduce

  1. Connect to a PostgreSQL database where the user only has access to a specific schema (not the full database)
  2. The database has other schemas (e.g. Supabase's realtime, auth) with identity columns
  3. Configure schemaFilter in drizzle.config.ts
  4. Run drizzle-kit studio
  5. Studio crashes with "Identity ... columns missing metadata: null"

Test plan

  • Verified locally with a Supabase PostgreSQL instance where the user only has access to a single schema (app_play4supabase_dev)
  • Studio now loads correctly and shows only the filtered schema's tables
  • schemaFilter is correctly read from drizzle.config.ts and passed through to the Studio proxy
  • Other drizzle-kit commands (push, generate) are not affected

Related issues: #2946, #4042

🤖 Generated with Claude Code

When connecting to a PostgreSQL database where the user only has
access to specific schemas (e.g. multi-tenant setups with schema-level
isolation, or Supabase with restricted roles), Drizzle Studio crashes
with "Identity columns missing metadata: null" because it tries to
introspect all visible schemas including ones the user cannot fully read.

This commit fixes the issue in two ways:

1. Graceful handling of missing metadata: Change throw to
   console.warn + continue in introspect functions when identity or
   generated column metadata is null, so a single inaccessible column
   does not crash the entire introspection.

2. Studio respects schemaFilter: Pass the schemaFilter config
   through to the Studio proxy server, and filter pg_namespace query
   results so the Studio frontend only sees schemas the user has
   configured. This prevents it from attempting to introspect schemas
   the user lacks privileges on.
@xiekw2010 xiekw2010 force-pushed the fix/studio-skip-identity-missing-metadata branch from 62c76a2 to d3ca341 Compare April 10, 2026 06:07
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.

1 participant