Skip to content

feat(api): flip auto_expose_new_tables default to false#5524

Open
avallete wants to merge 6 commits into
developfrom
claude/magical-gates-32n00o
Open

feat(api): flip auto_expose_new_tables default to false#5524
avallete wants to merge 6 commits into
developfrom
claude/magical-gates-32n00o

Conversation

@avallete

@avallete avallete commented Jun 9, 2026

Copy link
Copy Markdown
Member

Implements the May 30, 2026 flip of the [api].auto_expose_new_tables implicit default from true to false, aligning local behavior with the new cloud default of revoking Data API privileges on newly-created entities in the public schema.

Summary

The auto_expose_new_tables flag is a tri-state configuration that controls whether new tables, views, sequences, and functions created in the public schema are automatically reachable through Data API roles (anon, authenticated, service_role). This change flips the implicit default behavior:

  • Unset (default): Now revokes default Data API GRANTs (new behavior, matching cloud)
  • Explicit true: Preserves legacy auto-expose behavior but emits a deprecation warning; field removed on 2026-10-30
  • Explicit false: Revokes GRANTs explicitly (same as unset)

Key Changes

Go CLI (apps/cli-go/):

  • Updated ApplyApiPrivileges() logic to revoke by default when the flag is unset or false
  • Added deprecation warning in config validation when auto_expose_new_tables = true
  • Created helper.MockApiPrivilegesRevoke() test utility to reduce duplication across test suites
  • Updated all affected tests in start_test.go, reset_test.go, and diff_test.go to expect privilege revocation
  • Updated config comments and template to reflect the new default behavior

TypeScript CLI (apps/cli/):

  • Implemented resolveAutoExposeNewTables() function to handle tri-state flag resolution
  • Updated startCommand to emit deprecation warning when flag is explicitly true
  • Changed default from true to false in stack configuration
  • Added unit tests for flag resolution logic

Documentation & Schema:

  • Updated config template comments in both Go and TypeScript CLIs
  • Updated JSON schema documentation to reflect the new default and deprecation timeline
  • Updated TypeScript config schema with accurate descriptions

Implementation Details

The privilege revocation is implemented via SQL statements that revoke default privileges for the postgres role on tables, sequences, and functions in the public schema for the Data API roles. This ensures newly-created entities require explicit GRANTs to be exposed through the Data API, matching the cloud platform's security posture.

The deprecation warning message includes the removal date (2026-10-30) to guide users toward removing the configuration field during the transition window.

https://claude.ai/code/session_01W2z1un8QYhPvaSpdzwDP6F

claude added 2 commits June 8, 2026 17:01
…ecate explicit true

Implements the 2026-05-30 cloud flip for the tri-state
[api].auto_expose_new_tables flag:

- Unset now behaves as false: the default Data API GRANTs on the public
  schema are revoked so new entities require explicit GRANTs. Go's
  ApplyApiPrivileges only short-circuits on explicit true, and the next
  shell read site / stack library default flip from `?? true` to `?? false`.
- Explicit true keeps the legacy auto-expose behaviour but now emits a
  one-time deprecation warning (Go config validation + next start command)
  pointing at the 2026-10-30 removal.
- Updated the config.toml templates, config schema descriptions, and docs
  config reference to describe the new implicit default and removal date.

Tests cover all three states (unset, true, false) in Go and TS, plus the
deprecation warning.
Replace the repeated three-statement default-privilege revoke mock chain
across the start, reset, and diff tests with a single
helper.MockApiPrivilegesRevoke(conn) helper, mirroring the existing
MockMigrationHistory pattern. The helper is self-contained (no start
import) to avoid an import cycle with the start package's internal tests.
@avallete avallete requested a review from a team as a code owner June 9, 2026 14:02
@blacksmith-sh

This comment has been minimized.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a16f3127cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/stack/src/createStack.ts Outdated
Comment thread packages/stack/src/createStack.ts Outdated
Comment thread packages/stack/src/createStack.ts Outdated
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase@5524

Preview package for commit 2aee3d0.

The auto_expose_new_tables default flip means database setup now revokes
the default Data API GRANTs when the flag is unset, which broke the
shared-mock tests in internal/start and internal/migration/squash that
did not expect the revoke statements. Route them through the existing
helper.MockApiPrivilegesRevoke helper.

Also revert the @supabase/stack createStack library default back to true:
the issue only flips the implicit default at the start-command read site,
which passes the resolved value explicitly. Flipping the library fallback
would silently revoke privileges for callers that do not read project
config (functions dev, branches switch), losing an explicit `= true`
opt-in.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fda05ee6a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli-go/internal/db/start/start.go
claude added 2 commits June 9, 2026 14:36
After merging develop, the new TestSetupShadowDatabase exercises the
extracted SetupShadowDatabase, which runs ApplyApiPrivileges during the
platform baseline. With auto_expose_new_tables unset the revoke now runs
between the initial schema and the regression template, so route the
mock through helper.MockApiPrivilegesRevoke.
@coveralls

coveralls commented Jun 9, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 27214624907

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.006%) to 64.642%

Details

  • Coverage increased (+0.006%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 20 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

20 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
internal/db/declarative/declarative.go 14 55.34%
internal/utils/git.go 5 53.33%
internal/db/start/start.go 1 81.23%

Coverage Stats

Coverage Status
Relevant Lines: 16265
Covered Lines: 10514
Line Coverage: 64.64%
Coverage Strength: 7.13 hits per line

💛 - Coveralls

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 821a9ecec4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +427 to 428
if utils.Config.Api.AutoExposeNewTables != nil && *utils.Config.Api.AutoExposeNewTables {
return nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Invalidate pg-delta caches for the default flip

When the flag is unset, this branch now runs the revoke SQL, but the declarative cache key still records the same auto_expose_new_tables=unset token in apps/cli-go/internal/db/declarative/declarative.go:694-698. Users with .temp/pgdelta baseline or declarative catalogs created before the May 30, 2026 flip and no explicit config value will therefore reuse snapshots built with the old auto-expose privileges during db schema declarative generate/sync, which can hide or emit bogus default-ACL diffs until they clear the cache or pass --no-cache; the cache key needs to include the effective default/version for the unset case.

Useful? React with 👍 / 👎.

The pgdelta/declarative baseline cache key folded in the raw tri-state
auto_expose_new_tables flag, encoding the unset case as a constant "unset"
token. Since baselineVersionToken keys on the Postgres image (not the CLI
version), upgrading to the release that flips the implicit default reused
caches built before the flip — when unset still meant auto-expose —
producing stale default-ACL baselines during db schema declarative
generate/sync.

Key on the effective value instead: unset now resolves to the same
revoke-by-default baseline as explicit false (matching
start.ApplyApiPrivileges), so it keys identically to false and differs
from the pre-flip "unset" token, self-invalidating stale caches.
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.

3 participants