Repository navigation
fix(cli): follow views in the extra search path schemas in gen types - #7515
Conversation
PostgREST follows views in db-extra-search-path to find a view's base tables. Pass [api].extra_search_path to typegen so generated view relationships match what PostgREST embeds at runtime.
CLI benchmark (Lightweight Commands): no changes foundCommit
API calls: unchanged for all 7 commands. Binary size: 134.7 MB, up 8.0 KB from 134.7 MB. Details: timing ranges, API calls per command, slowest phasesTiming ranges
API calls per command
Slowest phasesNo command moved beyond noise, so there are no phase deltas. Comment |
Read [api].extra_search_path before any API call or connection, share the config load with the legacy local path, and cover the preview branch path.
There was a problem hiding this comment.
🤖 AI Review
Reconciled all five findings. Four are confirmed, with the config-bypass regression narrowed to preview-branch fallback and the coverage finding narrowed to missing assertions. The repeated-parsing claim is refuted because config loading is cached. Both independent reviews were available.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟡 MINOR | apps/cli/src/commands/gen/types/types.handler.ts:529 |
error-handling |
claude | Preview-branch generation with an explicit --schema now loads the full local config through resolveExtraSearchPath. A malformed or duplicate-remote config can therefore abort an invocation that previously bypassed config loading. The comment at line 315 still claims --schema skips the config load. |
| 🟡 MINOR | apps/cli/src/commands/gen/types/types.handler.ts:459 |
correctness |
claude | Hosted project and preview-branch introspection use the resolved local extra search path rather than the hosted PostgREST setting. When those values differ, introspection can derive relationship metadata using a search path that the hosted API does not use. |
| ⚪ NIT | apps/cli/src/commands/gen/types/types.integration.test.ts:1000 |
test-coverage |
claude | The new tests do not assert extraSearchPath on preview-branch fallback or pin the outcome of --schema combined with invalid or duplicate-remote config. |
| ⚪ NIT | apps/cli/src/commands/gen/types/types.handler.ts:263 |
naming |
codex | The new loadProjectConfig helper uses the hosted-config name for a local CliConfig loader, contrary to ADR 0020. |
Refuted findings (kept for transparency, not posted as review comments)
apps/cli/src/commands/gen/types/types.handler.ts:743(performance): Without --schema, URL and linked generation load and parse the project config twice for schemas and extraSearchPath, with a third load on the local legacy path.
Refuted: Repeated calls do not imply repeated parsing. cli-config-values.layer.ts:612-633 caches successful resolved configs indefinitely using structural LoadKey values. The schema and extra-search-path helpers pass identical keys. Additionally, :242-256 caches parsed documents by workdir, including across loads with different tolerance options. Sharing a resolved value could simplify the handler, but the claimed repeated-parsing cost is absent.
Stats
Claude findings: 4 · Codex findings: 1 · Confirmed: 4 · Refuted: 1 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
…e source Rename the config loader to the CliConfig vocabulary, test that a malformed config fails before any API call even with --schema, and document that remote projects read the extra search path from config.toml rather than the hosted setting.
Coly010
left a comment
There was a problem hiding this comment.
LGTM, thanks! Ran it against a local Postgres with the api -> extra -> private view chain and Views.invoices.Relationships now has the fkey (empty on develop).
Not a blocker, but linked TS generation still goes through the Management API, so --linked won't pick this up. Might be worth a follow-up if we want it there too.
Check code quality failed on a mise download (curl 22), so it just needs a re-run.
Problem
PostgREST derives a view's relationships by following views in the exposed schemas and in
db-extra-search-path.gen typesonly followed the generated schemas. When a view chain passed through an extra search path schema, its relationships were lost, so the types rejected embeds that work at runtime.supabase gen types --schema api,Views.invoices.Relationships:Change
@supabase/typegento 0.3.2 (postgrest-typegen 0.7.0, feat(postgrest-typegen): follow views in extra search path schemas sdk#329), which takes anextraSearchPathoption.[api].extra_search_path:--local,--remote=<db-url>, and remote projects or branches with a non-TypeScript--lang. For a project ref, the matching[remotes]block applies, like it does for[api].schemas.--schema, because it describes the target's PostgREST, not which schemas to generate. Without aconfig.toml, the defaultpublic, extensionsapplies.--schemaor[api].schemasnames it.