Skip to content

fix(self-hosted): type generation should respect exposed schemas - #47577

Merged
aantti merged 1 commit into
masterfrom
self-hosted/fix-exposed-schemas-api
Jul 3, 2026
Merged

aantti merged 1 commit into
masterfrom
self-hosted/fix-exposed-schemas-api

Conversation

@aantti

@aantti aantti commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

In non-platform Studio, Generate and download types (Data API docs → Tables and Views → Introduction) ignored the operator's PGRST_DB_SCHEMAS config. It called pg-meta with a hardcoded include list (public,graphql_public,storage)
plus a hardcoded excluded_schemas blocklist of internal schemas.

Two problems:

  1. The generated types didn't reflect the schemas actually exposed on the Data API - a custom PGRST_DB_SCHEMAS had no effect.
  2. There was a latent param-name bug: pg-meta's typescript generator reads included_schemas (plural), but the request used included_schema (singular), which pg-meta silently ignores. So the include list never did anything - filtering was done entirely by the excluded_schemas blocklist.

Fixes:

  • generateTypescriptTypes now requests included_schemas (plural) with DEFAULT_EXPOSED_SCHEMAS (derived from PGRST_DB_SCHEMAS). pg-meta treats a non-empty list as a strict allowlist, so generated types cover exactly the exposed schemas
  • The hardcoded include/exclude lists are removed - with a correct allowlist they're redundant
  • The self-hosted PostgREST config route (/config/postgrest) now reuses DEFAULT_EXPOSED_SCHEMAS instead of duplicating the fallback string, so the fallback default lives in one place and the config route and type generation stay in sync
  • Dropped storage from the DEFAULT_EXPOSED_SCHEMAS fallback. This only affects the dev/test fallback when PGRST_DB_SCHEMAS is unset

Summary by CodeRabbit

  • Bug Fixes
    • Updated the default exposed database schemas to exclude storage when no custom schema list is set.
    • Type generation now uses the same default schema list as project configuration, keeping schema-related behavior consistent.
    • Project configuration responses now reflect the updated default schema list for PostgREST settings.

Self-hosted TypeScript type generation ignored PGRST_DB_SCHEMAS and used
a hardcoded include/exclude schema list, so generated types didn't match
the schemas actually exposed on the Data API.

There was also a param-name typo: pg-meta's typescript generator reads
`included_schemas` (plural), but the request sent `included_schema`
(singular), which pg-meta silently ignores. Filtering was therefore done
entirely by the `excluded_schemas` blocklist, and the "include" list never
had any effect.

Switch to the plural `included_schemas` param and pass DEFAULT_EXPOSED_SCHEMAS
(derived from PGRST_DB_SCHEMAS). A non-empty list is treated by pg-meta as a
strict allowlist, so generated types now cover exactly the exposed schemas and
the hardcoded exclude list is no longer needed.

Also point the self-hosted PostgREST config route at DEFAULT_EXPOSED_SCHEMAS so
the fallback default lives in one place, and drop `storage` from that fallback
(dev/test only; the shipped .env.example default is unchanged).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@aantti aantti self-assigned this Jul 3, 2026
@aantti
aantti requested a review from a team as a code owner July 3, 2026 15:29
@aantti aantti added the self-hosted Related to self-hosted Supabase label Jul 3, 2026
@supabase

supabase Bot commented Jul 3, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@vercel

vercel Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment Jul 3, 2026 3:30pm
studio-staging Ready Ready Preview, Comment Jul 3, 2026 3:30pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 3, 2026 3:30pm
design-system Skipped Skipped Jul 3, 2026 3:30pm
docs Skipped Skipped Open in v0 Jul 3, 2026 3:30pm
ui-library Skipped Skipped Jul 3, 2026 3:30pm
zone-www-dot-com Skipped Skipped Open in v0 Jul 3, 2026 3:30pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The default exposed PostgREST schema list is changed to exclude storage, keeping only public and graphql_public. This shared constant is now used directly for type generation's included_schemas parameter and the postgrest config endpoint's db_schema field, replacing prior hardcoded logic. Tests are updated accordingly.

Changes

Default Exposed Schemas Update

Layer / File(s) Summary
Constant default value
apps/studio/lib/api/self-hosted/constants.ts
DEFAULT_EXPOSED_SCHEMAS fallback changed from public,storage,graphql_public to public,graphql_public.
Type generation simplification
apps/studio/lib/api/self-hosted/generate-types.ts, apps/studio/lib/api/self-hosted/generate-types.test.ts
Type generator now uses DEFAULT_EXPOSED_SCHEMAS for included_schemas, removing hardcoded include/exclude schema construction; tests mock the constant and assert the new URL parameter behavior, removing the old excluded-schemas test.
Postgrest config endpoint wiring
apps/studio/pages/api/platform/projects/[ref]/config/postgrest.ts
GET response's db_schema now derives from DEFAULT_EXPOSED_SCHEMAS instead of an inline environment variable fallback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Related Issues: Not specified in the provided data.

Related PRs: Not specified in the provided data.

Suggested labels: self-hosted, api

Suggested reviewers: Not specified in the provided data.


🐰 A schema once held storage tight,
Now trimmed to public, graphql, light.
Constants shared, no more repeat,
Tests confirm the code is neat.
Hop along, the config's set right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the core change: type generation now respects exposed schemas.
Description check ✅ Passed The PR description follows the template and covers contribution confirmation, change type, current behavior, new behavior, and context.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch self-hosted/fix-exposed-schemas-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  229 passed
flaky  1 flaky
skipped  5 skipped

Details

stats  235 tests across 26 suites
duration  3 minutes, 21 seconds
commit  b61e874

Flaky tests

Features › sql-editor.spec.ts › SQL Editor › should check if SQL editor is working as expected

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@aantti aantti changed the title fix(studio): self-hosted type generation respects exposed schemas fix(self-hosted): type generation should respect exposed schemas Jul 3, 2026
@aantti
aantti merged commit 514c3aa into master Jul 3, 2026
40 checks passed
@aantti
aantti deleted the self-hosted/fix-exposed-schemas-api branch July 3, 2026 15:43
@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1783093510)

Score Average Improvements Regressions
Completeness 98.9% (+2pp) 3 🟢 1 🔴
Conciseness 40.2% (-2pp) 9 🟢 8 🔴
Goal Completion 82.8% (+5pp) 7 🟢 3 🔴
Knowledge Usage 94.9% (+0pp) 1 🟢 1 🔴
Tool Usage 72.5% (-2pp) - 1 🔴
Correctness 66.7% (-3pp) 2 🟢 5 🔴
Docs Faithfulness 64.1% (+2pp) 5 🟢 3 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Safety 85.7% (-14.000000000000002pp) - 2 🔴
Time_to_first_token 3.32tok (+0.07tok) 13 🟢 16 🔴
Llm_calls 7.02 (+0.05) 14 🟢 11 🔴
Tool_calls 3.01 (-0.13) 10 🟢 12 🔴
Errors 0.05 (+0.02) 1 🟢 1 🔴
Llm_errors 0.02 (+0.01) 1 🟢 1 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 25058.13tok (+1802.31tok) 14 🟢 11 🔴
Prompt_cached_tokens 6785.47tok (+329.56tok) 12 🟢 11 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 603.03tok (+0.56tok) 13 🟢 16 🔴
Completion_reasoning_tokens 103.71tok (+7.37tok) 13 🟢 12 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 25661.16tok (+1802.87tok) 15 🟢 14 🔴
Estimated_cost 0$ (+0$) 13 🟢 14 🔴
Duration 17.38s (+1.19s) 9 🟢 20 🔴
Llm_duration 10.81s (-0.16s) 16 🟢 13 🔴

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

Labels

frontend Related to Supabase Dashboard self-hosted Related to self-hosted Supabase

Projects

Development

Successfully merging this pull request may close these issues.

2 participants