fix: studio crashes when user lacks privileges on some schemas#5618
Open
xiekw2010 wants to merge 1 commit intodrizzle-team:betafrom
Open
fix: studio crashes when user lacks privileges on some schemas#5618xiekw2010 wants to merge 1 commit intodrizzle-team:betafrom
xiekw2010 wants to merge 1 commit intodrizzle-team:betafrom
Conversation
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.
62c76a2 to
d3ca341
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem: Drizzle Studio crashes with
Identity realtime.subscription.id columns missing metadata: nullwhen 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
throwtoconsole.warn+continuein 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 theschemaFilterconfig fromdrizzle.config.tsthrough to the Studio proxy server. The proxy now filterspg_namespacequery 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
realtime,auth) with identity columnsschemaFilterindrizzle.config.tsdrizzle-kit studioTest plan
app_play4supabase_dev)schemaFilteris correctly read fromdrizzle.config.tsand passed through to the Studio proxydrizzle-kitcommands (push,generate) are not affectedRelated issues: #2946, #4042
🤖 Generated with Claude Code