mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
create-pull-request/patch
1526
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
79e7836a5a | feat(pipelines): Add support for unknown destination (#53272) | ||
|
|
53ffdf75c9 |
Joshenlim/fe 4945 cmd k support searching for all table (#53262)
## Context Probably the final piece for this series of changes towards resource aware Cmd K. We currently only present results for tables when searching in Cmd K, this PR adds in other entity types like views, materialized views, foreign tables, and partitioned tables (only the parent) Note that the results excludes entities created from database extensions to reduce the chance of noise <img width="500" alt="image" src="https://github.com/user-attachments/assets/27bf5026-937a-4883-b365-75694d551a39" /> ## Related changes - Tweaked the entity icon for partitioned tables a little to be blue (previously gray) and - Added an entity icon for child partition tables in the table editor that's slightly lighter than the partition table icon, currently child partition tables just render with the same icon as tables which can be confusing <img width="286" height="128" alt="image" src="https://github.com/user-attachments/assets/638af7c3-512d-4264-bfae-0a8827b3ef94" /> - Note that i'm planning to look into this separately RE how to better render child partition tables so this might go away subsequently ## Performance As always, ran a claude benchmarking session - this runs on debounced keystrokes against a live catalog, so it's benchmarked at scale: **45,653 `pg_class` rows** - 12k tables - 3,143 views - 3,002 matviews - 3,001 foreign tables) Taking a median of 15 runs, all variants measured against the same catalog in one process. | scenario | query | master | this PR | worst | |---|---|---|---|---| | exact table name | `t_500` | 19.5ms | 24.3ms | 29.1ms | | view name | `v_10` | 19.3ms | 23.7ms | 25.8ms | | foreign table name | `ft_10` | 18.9ms | 24.1ms | 26.9ms | | no match | `zzz_nothing` | 19.4ms | 24.0ms | 27.5ms | | broad prefix (~3k matches) | `t_1` | 30.8ms | 38.7ms | 45.1ms | | broad matview prefix | `mv_1` | 26.6ms | 37.5ms | 41.7ms | |
||
|
|
f38928ad90 |
fix(studio): resolve disk limits from the project's instance configuration (#52367)
## Problem Studio validates disk IOPS/throughput against one minimum value per compute size. Projects whose hardware supports more get blocked below their actual limits, charts and banners can show the wrong baseline, and burst charts are gated by a hardcoded size list that is wrong for some configs. Fixes PROD-674 ## What changed - New per-configuration limits table: `packages/shared-data/instance-disk-limits.ts` (values from the AWS EBS-optimized tables). - The size-wide floors in `compute-disk-limits.ts` are now derived from that table as per-size minimums. Published values are unchanged and pinned in tests. - New `useProjectDiskLimits()` resolves a project's limits from its primary database, falling back to the floors. - Disk form validates against the project's actual limits (floors when a different compute size is selected). New inline hint when provisioning between baseline and max. - Burst charts/tiles/metrics show only if baseline is below max. - Chart reference lines and the disk IO banner use the resolved values. ## How to test 1. Settings → Database → Disk on a Large+ project: IOPS/throughput accept values up to the project's actual limits, error above them, and show the burst hint between baseline and max. 2. Reports: burst metrics are offered only for projects whose disk IO bursts; a saved burst chart on a non-bursting project renders an "unavailable" placeholder instead. 3. `pnpm --filter studio vitest run components/interfaces/DiskManagement/DiskManagement.test.ts data/reports/database-charts.test.ts` --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
00adb5a81b |
chore(studio): remove the Iceberg pipeline destination (#52229)
## Problem Retire the deprecated Iceberg (Analytics Bucket) destination from Pipelines. ## Solution - Remove the destination UI, configuration mappings, feature-flag usage, and generated API variants. - Remove the legacy Pipelines integration from Storage while preserving standalone Analytics Buckets. - Remove unused components and sheet-layout support, and add regression coverage for retained Storage operations. - Remove the stale Pipelines claim from the Storage docs overview. ## Validation - Pipelines, Storage, and replication data tests - After the final cleanup: Studio typecheck and all 3 Analytics Bucket regression tests passed. - Formatting, scoped ESLint, Knip, and whitespace checks passed; lint warnings are pre-existing. - Storage overview: Prettier, ESLint with zero warnings, content-listing schema validation, and Markdown rendering passed. Production API-type verification remains pending the coordinated API deployment. Legacy Iceberg pipelines, destinations, and slots must be cleaned up before rollout. ## Review instructions 1. Verify that Pipelines offers BigQuery, DuckLake, Snowflake, and ClickHouse, with no Analytics Bucket option. 2. Verify that Storage Analytics Bucket creation, namespace/table operations, and wrapper/key cleanup remain available without Pipelines controls. ## Checklist - [x] Read CONTRIBUTING.md. - [x] Updated the Storage overview copy and checked the docs authoring guidance. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> |
||
|
|
5eb68c5df2 |
Add indexes to cmd k related resources in table editor (#53204)
## Context We previously added a "Related resources" section in Cmd+K if you're on the Table Editor with a table opened, this included resources pertaining to the table such as policies, triggers, and functions. We're adding indexes as well in this PR - thinking that might also be appropriate to have in this context <img width="500" alt="image" src="https://github.com/user-attachments/assets/5cd383ff-6617-49ba-bdb8-6f65d8fd0680" /> ## Performance Benchmarked with Claude against the stress catalog (`PG_META_STRESS_TABLES=12000`), with master and this branch timed in the same run on the same database, median of 9. | Table | master | This PR | Worst of 9 | |---|---|---|---| | Hub table — 8 indexes, policy, many FK triggers | 1.6 ms | 2.3 ms | 2.8 ms | | Policy + user trigger | 1.0 ms | 1.3 ms | 2.0 ms | | Mid-chain table | 1.1 ms | 1.5 ms | 1.7 ms | | Deliberately over-indexed table — 20 indexes | 0.8 ms | 2.0 ms | 4.6 ms | | Table that doesn't exist | 1.1 ms | 1.5 ms | 4.5 ms | |
||
|
|
395a54f2b7 |
feat(studio): gate jwt signing keys, legacy api keys, and third-party auth on grants (#53241)
Resolves [FE-4732](https://linear.app/supabase/issue/FE-4732/grants-rollout-jwt-signing-keys-legacy-api-keys-and-third-party-auth). ## Changes Gates the JWT signing keys, legacy API keys, and third-party auth endpoints on grants instead of `unguarded.migrating`, and replaces their V2 permission guards with `useGrant`: - **Data layer (11 sites):** `data/jwt-signing-keys/*`, `data/api-keys/legacy-api-keys-status-query`, `data/api-keys/legacy-api-key-toggle-mutation`, and `data/third-party-auth/*`. Queries become grant-gated query option factories; mutations take the grant in their variables. - **Consumers:** the JWT settings page, the JWT signing keys table and its dialogs, `jwt-settings`, `ToggleLegacyApiKeys`, `Project/APIKeys`, and the third-party auth page, form, and create dialogs. Each consumer renders denied and error states. - **JWT signing keys table:** - It's gated only on the signing keys reads (`GET signing-keys` and `GET signing-keys/legacy`, both `auth_signing_keys_read`). - The legacy API keys status is only used by the revoke dialogs. If it can't be read, revoking the legacy JWT secret fails closed: the user sees the "disable legacy API keys first" warning, with copy explaining why, instead of the confirm modal. - **Legacy JWT secret query:** a 404 (secret not imported as a signing key yet) resolves to `null` and shows the "Migrate JWT secret" panel. Other errors now render an error instead of being treated as "not migrated". - **Write actions:** - `getWriteGrantTooltip` moves from `APIKeys.utils` to `lib/grants` and takes a resource noun. Disabled write actions use it to explain why they're disabled. - New `getWriteGrantToastMessage`: handlers that run without a grant now show a toast instead of silently doing nothing. This includes the API keys handlers from #52966. ## Permission changes - **Legacy API keys toggle and status** (`GET`/`PUT /v1/projects/{ref}/api-keys/legacy`): the guard moves from `auth_signing_keys_read`/`_write` to the endpoint annotation, `api_gateway_keys_read`/`_write`. The annotation was confirmed against the backend controller (FE-4728). As a result, the JWT signing keys table's legacy revoke check now depends on `api_gateway_keys_read`. - **API keys last-used analytics** (`/platform/projects/{ref}/analytics/endpoints/api_keys.last_used.otel`): this endpoint uses legacy permissions (`analytics:Read` on `logflare`), not FGA. Its check moves from the V2 `auth_signing_keys_read` check to `useAsyncCheckPermissions(PermissionAction.ANALYTICS_READ, 'logflare')`. - Every other guard already matched its annotation: - `auth_signing_keys_read`/`_write` for signing keys - `auth_config_read`/`_write` for third-party auth ## Testing - Data layer: `jwt-signing-keys.test.ts`, `legacy-api-keys.test.ts`, and `third-party-auth.test.ts` cover every migrated fetcher, check that factories stay disabled without a grant, and cover legacy-key 404 vs. 500. - `jwt-secret-keys-table/index.platform.test.tsx`: - Legacy status denied: the table still renders, and revoking the legacy key shows only the warning. - Legacy status known enabled or disabled. - Signing keys read denied. - Legacy key 404 vs. 500. - `create-key-dialog.platform.test.tsx`: triggering create without a grant shows the toast and sends no request. - `ToggleLegacyApiKeys.platform.test.tsx`, `ThirdPartyAuthForm.platform.test.tsx`, and `settings/jwt/index.platform.test.tsx`: granted, denied, error, and partial-permission cases. - `lib/grants.test.ts`: the tooltip and toast helpers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) |
||
|
|
c8aad267cb |
fix(studio): use read grant variant for table related resources queries (#53231)
Fixes the Studio typecheck failure on \`master\`. ## What Two PRs merged close together and conflict at the type level. #53079 added the table related resources queries with a plain \`POST /platform/pg-meta/{ref}/query\` grant. #53185 then made a variant required for that endpoint. Both queries only read data, so they now request and accept the \`read\` variant. ## Testing - \`tsc --noEmit\` in \`apps/studio\` passes. |
||
|
|
1353178ac9 |
feat(studio): add read/write grant variants for pg-meta query (#53185)
Resolves FE-4729. First PR of the SQL grants series (FE-4697).
## What
Adds the mechanism for read and write grants on `POST
/platform/pg-meta/{ref}/query`. Every caller keeps `unguarded.migrating`
until its domain PR.
- `fga-refinements.ts`: `read` (`database_read`) and `write`
(`database_write`) variants, with `variantRequired`.
- `@supabase/pg-meta`: a `WriteSqlFragment` brand and `asWriteSql()`.
`safeSql` and `joinSqlFragments` return `WriteSqlFragment` when any
input is one, so composing write SQL keeps the brand.
- `executeSql`: overloads tie the grant to the SQL type. Write SQL needs
a write grant; other SQL takes a read or write grant.
## Notes
- The write check is type-only. Nothing in a pg-meta query request marks
it as a write, so the development-only `assertGrant` can't detect one.
The branch variants make the same trade-off, and the backend enforces
permissions either way.
- SQL written from scratch still needs `asWriteSql` where it's built.
Domain PRs mark their builders.
- Server-side callers (AI tools) will use `unguarded.byDesign`: they
forward the user's token, so the platform API enforces permissions.
FE-4750 applies this.
## Testing
- Type tests: grant/raw-client equality for both variants, rejection of
plain and unknown-variant grants, read/write brand invariance,
`executeSql` and `mutate()` rejecting write SQL with a read grant, and
brand propagation through `safeSql` and `joinSqlFragments`.
- `unguarded.migrating` count unchanged.
|
||
|
|
de63769998 |
feat(studio): add ability to purge CDN cache to storage UI (#52777)
## Problem Users should be able to purge the CDN cache for an individual object or entire bucket via the UI. This feature is only available for Pro+ customers. Free tier customers should be encouraged to upgrade to get access. ## Solution - Add a _Purge CDN cache_ action to the bucket menu. Prompt users on Free plan to upgrade if needed. <img width="182" height="149" alt="image" src="https://github.com/user-attachments/assets/b665c8d0-b540-400e-a328-85c48ddafee0" /> <img width="534" height="242" alt="image" src="https://github.com/user-attachments/assets/15dfd3d3-c8a9-4ad7-9046-0929fd715511" /> <img width="538" height="211" alt="image" src="https://github.com/user-attachments/assets/3e29644e-9335-4b1d-b321-49303c2e8476" /> - Add a _Purge CDN cache_ action to the bucket item menu. Prompt users on Free plan to upgrade if needed. <img width="283" height="313" alt="image" src="https://github.com/user-attachments/assets/a801297e-04b5-46c7-aaf7-4569e66e4714" /> <img width="541" height="249" alt="image" src="https://github.com/user-attachments/assets/b58d264b-76ba-43d4-9579-6c07be9cb684" /> <img width="537" height="207" alt="image" src="https://github.com/user-attachments/assets/132b37bd-3a29-48b5-aa7e-7df29abcbfe6" /> ## Notes - Refactored the _Edit bucket_ menu so that only one modal is allowed - Fixed focus management related to the modals displayed by the _Edit bucket_ menu items - Introduced a way to mock the authenticated users in tests ## Review instructions - On an org on at least _Pro_ plan - Open a bucket _Edit bucket_ menu and click _Purge CDN cache_ - Confirming should call the `/platform/storage/{ref}/cdn/purge-bucket` API endpoint - Open a bucket item menu and click _Purge CDN cache_ - Confirming should call the `/platform/storage/{ref}/cdn/purge-object` API endpoint - On an org on _Free_ plan - Open a bucket _Edit bucket_ menu and click _Purge CDN cache_ - You should be prompted to upgrade - Open a bucket item menu and click _Purge CDN cache_ - You should be prompted to upgrade --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> |
||
|
|
4d28d1a809 |
feat(studio): throw MalformedResponse for empty JSON GET bodies (#53182)
Follows supabase/supabase#53048. Part of [FE-4772](https://linear.app/supabase/issue/FE-4772/error-core-tagged-error-types-and-rough-fault-classification-in). ## What `normalizeEmptyBodyResponse` already tries to recover empty success bodies (original body, then one `no-store` refetch). When a JSON `GET` is still empty after that, it now throws `MalformedResponseError` (reason `empty_body`) carrying `endpoint`, `method`, `requestId` and status, instead of resolving with `{}`, which crashes components. * Unchanged: 204s, `HEAD`, non-`GET` requests and empty non-JSON responses keep the `Content-Length: 0` normalization. * Reporting: the error rejects like a network failure, so React Query gets the tagged instance and `reportQueryError` reports it once after the last retry. The refetch diagnostics are attached as Sentry context, and the standalone empty-body diagnostic event is skipped for this case to avoid double reporting. Recovered cases still send the diagnostic. * Routing: `MalformedResponse` moves to `SAMPLE_ALWAYS`. It is rare, and while we confirm the recovery path is sufficient every unrecovered case should be visible. * An abort during recovery throws `RequestAborted`, not `MalformedResponse` ## Notes * Callers using `get()` directly outside React Query are not reported automatically, same as network errors. * No GET endpoint showed up as legitimately returning an empty JSON body in the existing empty-body diagnostics. ## Testing * `pnpm vitest run data lib components/interfaces/ErrorHandling state` passes. * Lint ratchet passes; `tsc` shows only a pre-existing error in `packages/ui-patterns` (`InstructionBlocks.tsx`). |
||
|
|
121de3dff7 |
feat(studio): gate api key create and delete on endpoint grants (#52966)
Part 6 of 6 in a stack for [FE-4731](https://linear.app/supabase/issue/FE-4731/grants-rollout-api-keys-consumers-that-only-need-publishable-keys). Based on #52965. ## Stack 1. #52961 Docs and project API docs consumers 2. #52962 Edge functions and vector bucket examples 3. #52963 Integrations landing data 4. #52964 Connect sheet and project connection popover; remove the transitional api-keys hooks 5. #52965 `reveal` refinement for single api-key reads; API key pill 6. 👉 #52966 API key create and delete ## Changes Gates the api-key write endpoints (both require `api_gateway_keys_write`) on grants instead of `unguarded.migrating`: - `api-key-create-mutation` and `api-key-delete-mutation` take the grant in their variables. - `APIKeyDeleteDialog` uses the `DELETE` grant instead of its V2 check, and is disabled with a tooltip when denied or errored. `SecretAPIKeys` and `PublishableAPIKeys` pass the grant to the mutation. - `CreateNewAPIKeysButton` and the create publishable and secret key dialogs mint the `POST` grant. Their triggers and submit buttons are disabled with a tooltip unless granted. - `useConnectedResourceMutations`: the api-key delete call takes the grant. Without it, the mutation shows an error toast and throws. **New guard:** creating API keys had no UI guard. Users without `api_gateway_keys_write` could open the dialogs and get a 403; the controls are now disabled for them. The delete guard already matched the annotation. Out of scope: the legacy API key toggle and status (FE-4732). ## Testing - `CreateAPIKeyDialogs.platform.test.tsx` (renamed from `CreateAPIKeyDialogs.test.tsx`, the mutation mock removed): denied and permission-check error disable the triggers and the submit button. - `APIKeyDeleteDialog.platform.test.tsx`: granted, denied, and permission-check error. - `data/api-keys/api-key-write-mutations.test.ts`: create and delete send their requests with a grant. 🤖 Generated with [Claude Code](https://claude.com/claude-code) |
||
|
|
3aa85cc774 |
feat(studio): show warning and error counts on the edge function status codes chart (#53171)
## Problem On the edge functions report, the Edge Function Status Codes chart shows a single combined count in its header, which is hard to read when responses include errors. The count would be more intuitive if it were broken down by status code. Resolves FE-4025. ## Solution Add **Warnings** (4xx) and **Errors** (5xx) counts to the right of the total in the chart header. This matches the request cards on the project home page, and uses the same warning and error definitions as the Logs Explorer filters. Per-code detail stays in the legend and tooltip. - The counts show the period totals by default and follow the hovered point, like the total does. - Charts opt in through a new optional `getHeaderStats` on `ReportConfig`, passed through `ReportChartV2` and `ComposedChart` to `ChartHeader`. Only the status codes report sets it, so other reports are unchanged. - The counts are summed from the existing pivoted status code series (`getStatusClassCounts`), so the log queries are untouched and both the BigQuery and otel paths work. - The chart's info tooltip now explains what warnings and errors mean. <img width="756" height="305" alt="Image" src="https://github.com/user-attachments/assets/808085f5-abd9-43ec-903b-dfa0d5e4f598" /> ## Review instructions 1. Run Studio and open **Observability → Edge Functions** for a project that has edge function traffic. 2. On the **Edge Function Status Codes** chart, check that **Warnings** and **Errors** appear next to the total, and that they match the 4xx and 5xx rows in the legend. 3. Hover the chart. The total, Warnings and Errors should all follow the hovered point, then return to the period totals when you move away. 4. Check that **Total Edge Function Invocations**, **Execution Time** and **Invocations by Region** show no Warnings or Errors. 5. Try a narrow viewport to check the header doesn't crowd the buttons. Unit tests cover the counting and the header (period totals, hover, and charts without stats): `pnpm exec vitest run components/interfaces/Reports components/ui/Charts`. ## Checklist Check all before review: - [ ] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) |
||
|
|
2ce7f1f33c |
experiment(studio): expanded onboarding survey (#45707)
Adds an optional onboarding survey to the new-organization form, so we
learn who new orgs are for and what they are building. Users in the
`org_form` arm of the `onboardingSurveyPlacement` PostHog flag see a
**Help improve Supabase** section. Users in `control` get today's form
unchanged and still record exposure, so the two arms can be compared;
users the flag doesn't assign get the existing form and record nothing.
**Changed:**
- **Survey on the new-org form**: asks **Who is this org for?** (plus
**How many people?** for companies) and **What are you building?** (AI
assistant or agent, AI search or knowledge base, B2B SaaS, internal
tool, consumer app, social or community, marketplace or booking,
e-commerce, developer tool or app builder, analytics or reporting,
other). Every question ends with **Prefer not to say**. Answers go to
`POST /platform/organizations/onboarding-survey` as `kind`, `size` and
`building`.
- **Follow-up card for a blank survey**: if the creator answers nothing,
a card in the bottom-right asks the same questions for 5 minutes after
the org is created (not on project creation pages). Only the creator
sees it, once, tracked in localStorage. A blank form sends nothing at
creation, because the platform keeps only the first survey response per
user and org. Skipping the card, closing it, or letting the 5 minutes
run out still saves the org type and size picked on the form.
- **Telemetry**: exposure for both arms, plus submit, submit failed,
dismissed (including `follow_up_expired` when the card times out) and
Answer clicked events with `surface` set to `org_form` or `follow_up`.
**Note:** I cut **How comfortable are you working with code?** from v1.
The survey endpoint doesn't accept `coding_experience` yet, and the
question is planned to move to the user level later.
## To test
Setup: override `onboardingSurveyPlacement` to `org_form` in the dev
toolbar. Close the Terms of Service banner first, since the follow-up
card shares its slot.
Tested on the PR preview:
- [x] Create an org with **Who is this org for?** and **What are you
building?** answered, expect one `POST
/platform/organizations/onboarding-survey` carrying `kind` and
`building` (plus `size` for companies), no `coding_experience` key, and
no `kind` or `size` in the org-create request. Observed: 204 with
`{"slug":"<slug>","kind":"COMPANY","size":"10","building":"b2b_saas"}`;
org-create body was `{"name":"<name>","tier":"tier_free"}`
- [x] Create an org with the survey left blank, then open its projects
page, expect the follow-up card; answer it, expect the same survey
request and a "Thanks for sharing" toast. Observed: no survey request at
creation; after answering, 204 with
`{"slug":"<slug>","kind":"PERSONAL","building":"consumer_app"}` and the
toast
- [x] Override to `control`, open the new-org form, expect the same form
as master (Name, Type, Company size with "How many people are in your
company?" for Company, then Plan), no survey section, and an
`onboarding_survey_placement_experiment_exposed` event with `variant:
control`. Observed: screenshots match master's form field for field; the
exposure arrived in PostHog with `variant: control`
- [x] Create an org with the survey left blank and don't act on the
follow-up card for 5 minutes, expect the card to disappear, one `POST
/platform/organizations/onboarding-survey` carrying the form's `kind`
(plus `size` for companies) and no `building`, and an
`onboarding_survey_dismissed` event with `reason: follow_up_expired`.
Observed (stored follow-up time moved to near expiry instead of
waiting): the card disappeared at the 5-minute mark with one 204
carrying `{"slug":"<slug>","kind":"AGENCY"}` and the `follow_up_expired`
event; an already-expired follow-up sends on page load; with the dialog
open past expiry nothing is sent until it is closed
## Linear
- fixes GROWTH-771
- part of GROWTH-1463
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
Co-authored-by: Pamela Chia <pamelachiamayyee@gmail.com>
Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
|
||
|
|
b9fd4f8bdf |
Fix TS (#53189)
### Context Just fixing TS issues from merging this [PR](https://github.com/supabase/supabase/issues/53079) |
||
|
|
f87de2f0d0 |
Joshenlim/fe 4593 cmd k related resources while in table editor (#53079)
## Context Building on towards resource-aware Cmd K, the changes done up so far have all been to allow users to search for database resources from anywhere in the project, with the intention to get you to the resource quickly without having to go through the navigation hierarchy of the dashboard. This PR explores a way to quickly glance related resources for a table in the Table Editor through Cmd K for that same intention, but listing out the policies, triggers or functions that run on the table that you're currently viewing in the Table Editor. E.g here we've got the `blog_authors` table opened: <img width="500" alt="image" src="https://github.com/user-attachments/assets/78c9b85f-cd30-4564-a264-c1a2a596d5c2" /> Policies and triggers are fairly straight forward since we can determine what's related by their target table. Functions are a bit more fuzzy as we're trying to find what's related by checking the function definition, if it does anything to the table. For e.g based on the screenshot above, `blog_handle_new_user` has this definition which was why it was flagged <img width="500" alt="image" src="https://github.com/user-attachments/assets/fb8f3be4-05df-4d87-8440-8b75d95546ae" /> We're also deliberately decoupling loading of policies + triggers and functions since searching functions takes slightly longer, so opting to load results of policies + triggers first, then lazy load functions subsequently once results are ready ## Performance As usual, ran a benchmarking session with Claude just to make sure that the added SQL doesn't cause any performance issues, these are aggregates of 4–5 runs. **Catalog size (stress catalog)** | Query | 2,000 tables | 10,000 tables | |---|---|---| | Policies and triggers, hub table (many FKs) | 0.1 ms | 0.5–1.3 ms | | Policies and triggers, ordinary table | ~0 ms | ~0 ms | | Functions, every body matches | 1.4 ms | 4–8 ms | | Functions, no match (full scan) | 1.8 ms | 7.3–7.7 ms | | Functions, table not visible | 0 ms | 0 ms | **Large function bodies** (random text, 2,000 tables plus 2,000 small functions, plus the large ones added) | Function source | Largest function | Functions: no match (full scan) | Functions: every body matches | |---|---|---|---| | 56 MB (600 functions) | 94 KB | ~50 ms | 2 ms | | 103 MB (+10 multi-MB) | 4.7 MB | ~92 ms | 2 ms | ## To test Use a project with a table that has at least one policy, one trigger, and a function that mentions the table in its body. - [ ] Open that table in the Table Editor and press Cmd+K. A **Related resources** section appears at the top with its policies, triggers, and functions. - [ ] Click a policy, a trigger, and a function. Each opens its editor on the right resource. - [ ] A trigger's function does not also appear under the functions rows. - [ ] Type part of one of those names. The section narrows to matching rows and the project-wide entity results appear below. A resource can appear in both. - [ ] Type something that matches nothing in the table. The section disappears rather than showing empty. - [ ] Clear the input. The full section comes back without a loading flicker, since the data is cached. - [ ] Open the table editor on a table with no policies, triggers, or referencing functions. Cmd+K shows no empty **Related resources** section. - [ ] Switch to a different table and press Cmd+K. The section shows that table's resources, not the previous table's. - [ ] Open Cmd+K from a non-Table Editor page, such as the SQL Editor. The section is not shown. - [ ] In the network tab, check that opening the menu sends one query for policies and triggers and one for functions. Typing sends no additional ones for this section. |
||
|
|
3a76beea91 |
feat(studio): classify fetch-layer errors with endpoint and method (#53048)
## Problem Follow-up to #52730. Resolves part of FE-4772. Fetch failures and aborts were classified as `UnexpectedError`, and HTTP error responses with empty, HTML, or plain-text bodies did too. ## Solution **Network failures and aborts keep their classification.** `fetchHandler` used to rewrite `Failed to fetch` into a plain `Error`, so openapi-fetch network failures were classified as `UnexpectedError`. It now throws `classifyError(err, { endpoint, method })`, giving `NetworkUnreachable` (same user-facing message, original error as `cause`) or `RequestAborted`. The endpoint comes from `schemaPath`, recorded in `onRequest`. Tagged aborts are no longer named `AbortError`, so `isRequestAborted()` checks for both. `state/storage-explorer.tsx` uses it, so cancelling a folder load no longer shows an error toast. **One place reads error responses.** `readResponseError` in `data/error-classification.ts` turns an HTTP error response into a `RawResponseError`. It reads the status, `Retry-After`, the message from a JSON body or a short `text/plain` body (never HTML), plus `requestId`, `endpoint`, and `method`. The openapi-fetch middleware serializes its result into the error body. openapi-fetch builds `error` only from the response body, so that step can't be skipped. `parseResponseErrorBody` now only checks the shape. Empty, HTML, and plain-text error bodies now classify by status. Before, they became `UnexpectedError`. `fetchGet`/`fetchPost`/`fetchHeadWithTimeout` (Studio's own `/api` routes) use the same helper. This also fixes a non-JSON error body making them reject with a `SyntaxError`. **`requestPathname` is replaced by `endpoint`.** The no-retry list and the statement-timeout check in `query-client.ts` match OpenAPI patterns exactly. Critical error messages in `lib/error-reporting.ts` use the pattern, so concrete project refs stay out of them. `path-to-regexp` is no longer used, so it's removed. ## Review instructions 1. From `apps/studio`, run `vitest run data lib components/interfaces/ErrorHandling state`. Expect 4,034 passing tests. 2. Review `readResponseError` in `data/error-classification.ts` and its use in `data/fetchers.ts`. ## Additional context ### Notes - Critical error messages now read `endpoint … w/ message: …`. This regroups those Sentry issues. - A JSON body's `error` string is now accepted as a message for API responses. Before, only the `/api` route path read it. ### Testing - New `data/fetchers-errors.test.ts` covers network failure, abort, empty/HTML/plain-text/JSON error bodies, service derivation, and `/api` route non-JSON bodies. - Unit tests for `readResponseError`, `isRequestAborted`, and the no-retry endpoint set. - `vitest run data lib components/interfaces/ErrorHandling state`: 4,034 pass. ## Checklist Check all before review: - [ ] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) |
||
|
|
529ca5aa1d |
fix(studio): update CPU usage docs link FE-4820 (#53168)
## Problem The CPU usage info icon was reported to open a 404 page. Its chart definition points to the former telemetry reports URL, which currently redirects to the observability guide. ## Fix Link directly to the CPU usage section at `/guides/observability/reports#cpu-usage`. ## How to test - Open the Database report and click the info icon next to CPU usage. - Expected result: the Reports guide opens at the CPU usage section. Verified this interaction in the Studio staging preview for commit `316d6a8ae87d52ba3d338da2151c1d7dd99d6339`. Prettier, typecheck/lint, lint ratchet, and all four Studio unit-test shards pass in CI. Local report tests and ESLint were blocked by missing installed dependencies (`effect` and `@eslint/compat`). No new test was added for a static URL change. |
||
|
|
e04c556bd5 |
feat(studio): add the issues list (#52990)
Add the Issues list, URL filters, and overview counts with complete advisor refresh handling. |
||
|
|
22c3587058 |
fix(studio): add sqlOrigin and queryName to row large values query (#53164)
## What Fixes the Studio typecheck failure on `master`. #53091 (copy large values when duplicating a row) added an `executeSql` call in `row-large-values-query.ts`. #53059 (split SQL errors into user and Studio SQL) made `sqlOrigin` and `queryName` required. Each PR passed CI by itself, but together they break typecheck. This PR adds the two fields, following the pattern used in the other `data/table-rows` queries. ## Verification - `pnpm typecheck` passes (17/17 tasks) |
||
|
|
c0e92057a6 |
feat(studio): split SQL errors into user and Studio SQL (#53059)
Part of FE-4772. ## Why Errors from the pg-meta query endpoint didn't say who wrote the SQL, so a Sentry issue like SUPABASE-APP-KXE couldn't tell a user's query from one Studio composed. That event came from the assistant's `execute_sql` tool and was captured by the Vercel AI integration on the server, so it skipped `reportStudioError` and had no fault tags. The Postgres message also went to Sentry as-is, and it can contain user SQL and data. ## What - **`sqlOrigin` is required on `executeSql`.** `'user'` covers SQL the user or an AI agent wrote, in whole or in part: SQL editor, editor panel, Explorer, AI `execute_sql` and `run_notebook`, report blocks, Query Insights EXPLAIN, the policy, function, and cron editors, and running a stored cron job. Everything else is `'studio'`. The policy, function, and cron mutation hooks and `useDbQuery` take `sqlOrigin` too. - **`classifySqlResponseError`** turns a 400 from the query endpoint into `UserSqlError` (`user`, `user_sql`) or `StudioSqlError` (`studio`, `studio_sql`). Pattern rules (connection timeouts) and other statuses keep their classes. - **`UserSqlError` never reaches Sentry.** Its routing is `SAMPLE_NEVER`, `alwaysCapture` doesn't override it, and `beforeSend` drops it. - **`StudioSqlError` is redacted.** Error classes can set `sentryMessage`; for `StudioSqlError` it is the SQLSTATE and the query's `queryName`, a static name that `executeSql` requires for Studio SQL. The query key is never reported, since its segments can hold IDs, schemas, and search terms. `applyStudioErrorPolicy` applies it from `beforeSend` on the client and the server, so it holds however the error was captured. The server config gets a `beforeSend` for this. Events get `query_name` and `sql_state` tags and are grouped by both, since every SQL error shares the `executeSql` stack. - **A custom `handleError` gets the classified error**, matching its declared type. The SQL editor, editor panel, and policy editor rethrow it, so their errors are now `UserSqlError` instead of being reported as `UnexpectedError`. The error keeps Postgres's `position` for the editor's line highlight. The error message, `formattedError`, and `position` stay on the error for the UI. The query-performance Sentry context no longer carries the raw error message, which bypassed redaction. ## Known gaps - Index advisor queries run users' query text from `pg_stat_statements` but are marked `'studio'`. Redaction keeps the text out of Sentry, but their failures count as Studio faults. - 5xx responses for user SQL are still `PlatformError` and keep their message. - The self-hosted MCP `executeSql` calls `executeQuery` directly and isn't covered. ## Testing - Unit tests for `classifySqlResponseError`, `applyStudioErrorPolicy`, and the client `beforeSend`. - Full Studio vitest suite passes except `useReportDateRange.test.ts` (169 vs 168 hourly buckets across the DST change), which this PR doesn't touch. |
||
|
|
011b7cd4ac |
feat(studio): derive issues from advisor lints (#52989)
Part 1 of 6: #52989 → #52990 → #52991 → #52992 → #52993 → #53138 Advisors becomes Issues. This PR maps lints to issues on the client: one issue per check, each lint an affected resource, plus one issue for banned IPs. There's no Issues API yet, so issues exist only while their check fails. Nothing renders them until #52990. ## How to test - Read `data/issues/lint-to-issue.ts`; the rest follows from it. - `pnpm --filter studio exec vitest run data/issues components/interfaces/Issues` --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Jordi Enric <jordi.err@gmail.com> |
||
|
|
4c68610167 |
feat(studio): copy large values when duplicating a row (#53091)
## What Follow-up to #52952. The grid truncates large columns (over 10 KB) in the database query, so \"Duplicate row\" used to leave those fields blank. It now fetches their full values and fills them into the Insert Row panel. ## Behavior - Truncated columns are fetched by primary key after the panel opens. Each one is disabled with \"Loading full value...\" until it arrives, and Save is disabled until every value has settled. Submitting the form another way (e.g. pressing Enter) is blocked too. - Only the truncated fields are filled in, so anything the user has edited is never overwritten. - If a value can't be copied, the field stays empty with a note saying why: - the value is over 1 MB (it isn't sent, so a single row can't pull an unbounded amount of data into the browser) - the table has no primary key - the fetch failed (also shows a toast) - The fetch honors \"View as role\", like the existing \"Load full\" buttons. ## How - New `useRowLargeValuesQuery` in `data/table-rows/` selects the truncated columns of one row in a single query. Each column is returned as `NULL` when it exceeds `MAX_ROW_LARGE_VALUE_BYTES`. The SQL is built with `ident()`, `literal()` and the Query builder. - A new `useCopiedLargeValues` hook owns the fetch and per-field status, to keep `RowEditor` from growing further. Pure helpers (`getTruncatedFieldNames`, `getPrimaryKeyMatch`, `mergeLargeValues`) are in `RowEditor.utils.ts`. - `InputField` takes an optional `status` and renders the note. ## Also changes `isValueTruncated` now compares byte length instead of character length. The query truncates when a value exceeds the limit in bytes but cuts by characters, so a value of multibyte characters could be truncated and still be shorter than the limit in characters, and wasn't detected. Comparing bytes still never flags a genuine value, because an untruncated value is at most the limit in bytes. Edit row's \"Load full\" buttons benefit from the same fix. ## Notes - A fetched value over 10 KB that genuinely ends in `...` still looks truncated to the existing check, so the form disables that field, as it already does when editing such a row. - A column that changed to `NULL` after the grid loaded also shows the \"too large\" note. ## Testing - Unit tests for the SQL builder (including identifier and literal escaping), the byte-aware detection, and the new helpers. - Component tests for `RowEditor`: the full value is fetched and included in the insert; field and Save are disabled while loading (including form submit); too large, fetch failure, and no primary key leave the field empty with a note; nothing is fetched when no value was truncated. I confirmed the loading test fails when the Save guard is removed. Resolves FE-4927 |
||
|
|
d69d8e1bc1 |
fix(studio): retry empty JSON GET responses without the HTTP cache (#53089)
## Problem
Successful GET requests sometimes reach Studio as a `200` with an empty
body. The fetcher turns these into `data: {}`, which doesn't match the
generated types, so components crash on nested reads such as
`pages[0].pagination.count`, `project.ref` and `features.vectorBuckets`.
Sentry diagnostics from #51123 show:
- Nearly all of these events come from Firefox.
- A `cache: 'no-store'` refetch of the same request returns a normal
body in more than 99% of events, so the API isn't sending empty
responses.
- The API sends no `Cache-Control` and a weak ETag, so Firefox
revalidates stored entries with `If-None-Match`. A browser cache or
revalidation bug is the most likely cause, but it isn't proven.
## Solution
When a successful response has an empty body,
`normalizeEmptyBodyResponse` now tries to recover it before falling back
to `{}`:
1. If only the clone used for the peek was empty, it reads the original
response and uses that body.
2. For JSON GET requests, it re-fetches once with `cache: 'no-store'`
and a new `X-Request-Id`, using plain `fetch` so the middleware can't
recurse. The retry uses the query's abort signal. A `2xx` response with
a body is returned to the caller.
3. Otherwise it keeps today's behavior: `Content-Length: 0`, which gives
`data: {}`.
The retry only covers GET requests with an `application/json` response,
so these stay unchanged:
- empty mutation responses
- the branch diff endpoint, which legitimately returns an empty
`text/html` body when there's no diff
The retry replaces the diagnostic probe, so a failure costs two requests
instead of three. The Sentry report gets a new `recovered_by` tag
(`original_body`, `refetch` or `none`), which will show whether the fix
works and whether the clone or the cache was at fault. The existing
`probe_*` fields keep their names, and Sentry still only receives body
lengths, never bodies.
### Why not bypass the cache for every request?
We chose not to send every request with `cache: 'no-store'`. It would
remove every `304 Not Modified` response, so unchanged data would come
back as a full `200` body each time and more data would go over the
network. The retry keeps HTTP caching for normal requests and only skips
the cache for requests that already came back empty.
## How to test
- `pnpm vitest run data/empty-body-diagnostics.test.ts
data/normalizeEmptyBodyResponse.test.ts` from `apps/studio` covers:
- refetch recovery, and the secret value never reaching Sentry
- fallbacks when the retry is empty, rejects, returns non-2xx or is
aborted
- no retry for non-JSON responses or non-GET requests
- the original-body path
- After release, check the `recovered_by` tag on the "Empty response
body on successful API request" Sentry issues, and confirm the related
crash issues (`pagination is undefined`, `can't access property "ref"`)
trend down.
Part of FE-4665
Related to FE-4912
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
||
|
|
1052d414ad |
fix(studio): verify identity before removing authenticators (#52352)
## Problem Authenticator removal can fail when the session has not completed MFA. This is difficult to test (see below) but shows an awkward toast with unclear “AAL1” and ”AAL2” copy, which is unhelpful to the user. ## Solution Checks the session before removal confirmation. If needed, shows _Verify your identity_ first. Depends on #52351. Badge presentation: #52748. Recovery-code verification: #52747. | After | | --- | | <img width="814" height="725" alt="Security Account Supabase" src="https://github.com/user-attachments/assets/8d0dc002-3777-4ba5-a4bc-9d98a059c2c4" /> | | _Unfilled state._ | | <img width="814" height="725" alt="63727" src="https://github.com/user-attachments/assets/5472de19-99b6-4403-aaca-f92e319445cb" /> | | _Errored state._ | | <img width="814" height="725" alt="27157" src="https://github.com/user-attachments/assets/f8480f0b-5cc4-432f-b38f-79cd311274cf" /> | | _What the above (success state) unlocks: being able to remove authenticator._ | ## Review instructions Use a disposable MFA account and sign in normally. 1. Open [Security locally](http://localhost:8082/account/security) (so the breakpoint feature can be used). Click Delete beside an authenticator. Since you already entered an MFA code at sign-in, removal confirmation should open directly. Cancel keeps the authenticator. Click Cancel. 2. To show verification, open DevTools → Sources → ⌘P. Find `mfa-authenticator-assurance-level-query.ts`. Inside `getMfaAuthenticatorAssuranceLevel`, click the line number beside **`return data`** to add a breakpoint, then (back in the Studio interface) click Delete. 3. When Paused in debugger appears, press Esc for the Console drawer (in DevTools) and run `data.currentLevel = 'aal1'`. Remove the breakpoint by clicking its line number again, then press F8 or Resume ▶ (at the top of Studio in the yellow strip). 4. Try an invalid authenticator code, then a valid one. Verification must lead to a separate removal confirmation. Cancel must keep the authenticator. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> |
||
|
|
c920e07d9c |
feat(studio): review a pending network restrictions change (#52984)
## Problem A network restrictions change that was never applied can now wait for the customer's review ([API Docs](https://api.supabase.com/api/v1#tag/projects/POST/v1/projects/{ref}/network-restrictions/review), [CTRL-1934](https://linear.app/supabase/issue/CTRL-1934)). Studio doesn't show it. Lists with an entry that isn't a valid IP range also fail to save without saying which entry is wrong. ## Solution - A change in review shows one callout with **Apply change** and **Discard change**, and both lists together: added entries in green, removed ones in red. Editing is disabled until it's resolved, and discarding asks for confirmation. Only the change on screen is resolved (`pending_requested_at`). - A list the worker is still applying shows as applying and is polled, instead of showing the "not applied correctly" error. - Entries that aren't valid ranges are marked Invalid with a suggested correction, and can be saved corrected. The add dialog rejects IPv4-mapped IPv6 addresses and finds duplicates spelled differently. There's no way to create a review yet: a change only ends up in review when the backend fails to apply a list. I tested the review state locally by editing the database directly. Stacked on #53046, which syncs the API types with production, including the review endpoint. This PR will be retargeted to `master` once that merges. ## Screenshots <img width="712" height="473" alt="Screenshot 2026-11-04 at 5 10 19 PM" src="https://github.com/user-attachments/assets/c72cc38d-f7b4-4269-a787-f27dfe382086" /> ### If pressing `apply` <img width="704" height="150" alt="Screenshot 2026-11-04 at 5 19 27 PM" src="https://github.com/user-attachments/assets/92dce8e5-8d58-48b8-8899-ed01c9f242c2" /> ### If pressing `discard` <img width="712" height="473" alt="Screenshot 2026-11-04 at 5 10 38 PM" src="https://github.com/user-attachments/assets/85656004-d510-4cef-89c1-80d9f95ebb83" /> ### Invalid <img width="754" height="596" alt="Image" src="https://github.com/user-attachments/assets/4ba480f6-af4c-4253-9693-2c545fb77ab1" /> ### Invalid repair <img width="704" height="680" alt="Screenshot 2026-11-04 at 6 03 20 PM" src="https://github.com/user-attachments/assets/ed4e3dcf-8d9b-4588-afc0-938248c78712" /> ### Invalid and Pending <img width="704" height="593" alt="Image" src="https://github.com/user-attachments/assets/7ad76b50-0d08-4505-89ad-b6afff6865af" /> ### Invalid and Pending repair <img width="704" height="585" alt="Screenshot 2026-11-04 at 6 05 04 PM" src="https://github.com/user-attachments/assets/b123453f-0f30-452d-b84c-a556c52458a0" /> ## Review instructions 1. Locally, put a project's network restrictions into review by editing the database directly. There's no API that creates one. 2. Open Database Settings > Network restrictions and check the callout and the added and removed entries. 3. Apply or discard the change. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) |
||
|
|
597d1ce56e |
fix(studio): pass caller options to grant-gated query factories (#53088)
## Context Grant-gated query factories returned `queryFn: skipToken` when the caller had no grant. TanStack Query keeps one options object per cache entry, overwritten by whichever observer rendered last. When that was a grant-less observer, invalidation refetched with `skipToken` and failed with `Missing queryFn`, breaking the query for every other observer on the key. #53075 patched two call sites; this fixes the factories. ## Changes - New `grantedQueryOptions` helper (`data/granted-query-options.ts`). Without a grant, the factory sets `queryFn: undefined` instead of `skipToken`, so TanStack borrows the query function from a subscribed observer that has one. The caller's `enabled` applies only when the factory has a query function. - `apiKeysQueryOptions`, `revealedApiKeysQueryOptions`, `branchesQueryOptions`, `branchQueryOptions` and `branchDiffQueryOptions` take caller options as a second argument. Call sites change from `useQuery({ ...f(vars), enabled })` to `useQuery(f(vars, { enabled }))`, so callers can't override the grant gate. - New type-aware `fga/no-spread-granted-query-options` lint rule (error). `grantedQueryOptions` returns a type-only brand, and the rule flags any spread or `Object.assign` of a branded value, however it was built or named. - Restores typed linting as a separate pass (`eslint.type-checks.config.cjs`, run by `pnpm lint` via `lint:type-checks`), as #44678 did. Enabling type info in the main config changes what other plugins report, so it stays separate. - `studio-queries` skill documents the pattern. Callers still pass their own grant, so the UI gates on the same grant the request carries. ## Testing - `data/api-keys/api-keys-query.test.tsx`: a granted and a grant-less component share the key, with the grant-less one rendering last; invalidation via the delete mutation refetches successfully. Fails on master with `Missing queryFn`. - `data/granted-query-options.test.ts`: `enabled` gating, factory fields win over caller fields, `select` type inference. - Lint rule cases in `scripts/__tests__/fga-eslint-rules.test.ts`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) |
||
|
|
fe7b3ad6af |
chore: bump @graphql-codegen and its deps (#52785)
## Problem `@graphql-codegen/cli` and related packages in `apps/studio` and `apps/docs` were pinned to old major versions (`cli` 5.0.5, `typescript` 4.1.6, `typescript-resolvers` 4.5.0). ## Solution - Bump `@graphql-codegen/cli` to `^7.0.0` and `@graphql-codegen/typescript-resolvers` to `^6.0.0`. Drop the explicit `@graphql-codegen/typescript` dependency from `apps/docs`. - Regenerate the Studio GraphQL output in `apps/studio/data/graphql/` with the new codegen. The generated files now include an `index.ts` export change, and `graphql.ts` is much smaller. - Refresh `apps/studio/scripts/schema.graphql`, which picks up the new `ManagementApiReference` search result type. - Update `.prettierignore` (ignore `apps/studio/.output`, `apps/studio/dist`, and all of `apps/ui-library/public`) and run Prettier on the regenerated files. ## Review instructions 1. Check the dependency bumps in `apps/studio/package.json` and `apps/docs/package.json`. 2. Re-run the Studio codegen and confirm it produces no diff in `apps/studio/data/graphql/`. 3. Run `pnpm typecheck` and confirm the GraphQL consumers in Studio still compile. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
06d43f6881 |
Joshenlim/fe 4721 cmd k support searching for triggers (#52755)
## Context Building off from [here](https://github.com/supabase/supabase/pull/52751) to make Cmd+K resource-aware so finding and inspecting anything in a project doesn't depend on knowing where it lives in the dashboard. Specifically looking into database entities for now - end state would be that you could search for a table name for example, and Cmd K will pull up everything related to that table for you to skim (e.g Policies, Functions, Triggers, etc). Changes in this PR sets up searching for **database triggers**, and will probably be the last database entity that we'll add into context aware cmd K for now given that we'll have tables, policies, functions and triggers which are the primary building blocks for a project. <img width="500" alt="image" src="https://github.com/user-attachments/assets/242ec517-88cd-4f3d-96ce-741edaa8560d" /> Triggers will also match if it's function matches the search input, and its description will tweak slightly as well <img width="500" alt="image" src="https://github.com/user-attachments/assets/65f515df-b875-4b92-95b7-00389d8a070b" /> ## Performance Had Claude do some benchmarking against `getSearchEntitiesSql` (`EXPLAIN ANALYZE`, median of 5 runs, local Postgres, warm cache) on one synthetic catalog: - 12,000 tables (36,651 `pg_class`), 6,001 policies, 27,261 `pg_proc` (12,000 user + 12,000 extension-owned functions), 56,304 `pg_trigger` - 3,500 user triggers, 500 of which run one shared function; the rest are internal FK triggers - 297,921 `pg_depend`. Compared against master (tables + policies) and the functions PR (before triggers). | Search | What it exercises | master | functions PR | this PR | Δ this PR | |---|---|---|---|---|---| | `t_1` | broad table match | 12ms | 26ms | 30ms | +4ms | | `p_1` | broad policy-name match | 15ms | 27ms | 35ms | +8ms | | `fn_1` | broad function match | 10ms | 26ms | 33ms | +7ms | | `trg_1` | broad trigger-name match | 9ms | 23ms | 32ms | +9ms | | `trg_` | every user trigger matches by name | 10ms | 25ms | 40ms | +15ms | | `audit_row_fn` | function match; its 500 triggers match only through the function | 9ms | 24ms | 31ms | +7ms | | `ri_constraint` | only internal FK triggers match | 9ms | 24ms | 30ms | +6ms | | `stress.fn_1` | schema-qualified | 12ms | 33ms | 40ms | +7ms | | `zzz` | no match | 9ms | 22ms | 27ms | +5ms | - Triggers add +4 to +15ms over the functions PR. The worst case is a search matching every user trigger, at 40ms in total. - Matching triggers through their function shares the single `pg_trigger` pass the name search already does, with no extra scan. A separate pass measured about 30ms more on every search. ## To test - [ ] Search a table name: Tables first, then policies, and functions, and triggers - [ ] Search a trigger name: it appears under triggers and opens the editor panel in database/triggers - [ ] Search a function name: trigger results should appear if the trigger uses that function - [ ] Trigger outside public: schema filter switches and the trigger opens |
||
|
|
757040ffc7 |
feat(studio): add reveal refinement for single api-key reads (#52965)
Part 5 of 6 in a stack for [FE-4731](https://linear.app/supabase/issue/FE-4731/grants-rollout-api-keys-consumers-that-only-need-publishable-keys). Based on #52964. ## Stack 1. #52961 Docs and project API docs consumers 2. #52962 Edge functions and vector bucket examples 3. #52963 Integrations landing data 4. #52964 Connect sheet and project connection popover; remove the transitional api-keys hooks 5. 👉 #52965 `reveal` refinement for single api-key reads; API key pill 6. #52966 API key create and delete ## Changes - Adds a `reveal` refinement for `GET /v1/projects/{ref}/api-keys/{id}`, mirroring the list endpoint: the `reveal` variant adds `api_gateway_keys_secret_read`, and the wrapper owns the `reveal` query param. - `getAPIKeysById` takes a plain or reveal grant instead of `unguarded.migrating` and a manual `reveal` flag. - `useRevealedSecret` mints the reveal grant, returns it, and doesn't request unless it's granted. - `ApiKeyPill` uses the reveal grant instead of its V2 check. Reveal and copy are disabled while the check loads, when denied, or when it fails. Publishable keys aren't gated. - `useConnectServerEnv`: the secret can only be revealed once the reveal grant is granted. **Guard drift:** `ApiKeyPill` checked only `api_gateway_keys_secret_read`, but the endpoint needs `api_gateway_keys_read` and `api_gateway_keys_secret_read`. Users with only the secret permission saw an enabled button and got a 403; they now see it as restricted. ## Testing - `data/guarded-fetch.test.ts`: type tests for the by-id endpoint (plain and reveal grants match the raw client, `reveal` rejected as a caller param, a list-endpoint reveal grant rejected), and a runtime test that `reveal` is set from the grant. The "variant the endpoint doesn't have" negative now uses the branches endpoint. - `ApiKeyPill.platform.test.tsx` (renamed from `ApiKeyPill.test.tsx`, now on real grants through MSW): reveal and copy when granted, denied (no request), permission-check error, publishable keys not gated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) |
||
|
|
1d0398db4b |
feat(studio): gate connect sheet and project connection popover on api-keys grants (#52964)
Part 4 of 6 in a stack for [FE-4731](https://linear.app/supabase/issue/FE-4731/grants-rollout-api-keys-consumers-that-only-need-publishable-keys). Based on #52963. ## Stack 1. #52961 Docs and project API docs consumers 2. #52962 Edge functions and vector bucket examples 3. #52963 Integrations landing data 4. 👉 #52964 Connect sheet and project connection popover; remove the transitional api-keys hooks 5. #52965 `reveal` refinement for single api-key reads; API key pill 6. #52966 API key create and delete ## Changes Moves the last publishable-key consumers onto the plain `GET /v1/projects/{ref}/api-keys` grant: - `ConnectSheet`: shows `ApiKeysAccessNote` under the mode selector (except the warehouse and server modes; the server panel has its own note) - `useConnectServerEnv`: `canReadAPIKeys` and its loading state come from the grant, and the hook returns the grant. The on-demand secret reveal is unchanged here (part 5 moves it). - Server env content: shows the note next to the disabled copy buttons - `ProjectConnectionPopover`: only fetches while open. The nested ternary for the key display is replaced with a flat helper covering loading, denied, error, and the key. With no callers left, the deprecated transitional `useAPIKeys` / `useAPIKeysQuery` hooks are removed from `data/api-keys/api-keys-query.ts`. The old guards matched the annotation. ## Testing - `ProjectConnectionPopover.platform.test.tsx` and `content/server/env/content.platform.test.tsx`: granted, denied (no request), and permission-check error. - `useConnectServerEnv.test.ts` updated for the grant. 🤖 Generated with [Claude Code](https://claude.com/claude-code) |
||
|
|
f4b60922e4 |
fix(studio): stop retrying client errors in the storage buckets query (#53026)
## Problem The storage buckets queries (`usePaginatedBucketsQuery`, `useBucketQuery`) override the global retry rule with `shouldRetryBucketsQuery`, which retried every error except 404 and two specific messages. A permanent client error, such as a 402 returned when a project's service is restricted, was retried 3 times with exponential backoff. The Storage files page showed its loading skeleton for that whole time instead of the error that `FilesBuckets` already renders. ## Solution `shouldRetryBucketsQuery` now skips retries for any 4xx response except 429. This matches the global default in `data/query-client.ts`. The existing checks for 404, "Missing tenant config" and "Project has no active API keys" are kept, with 404 now covered by the 4xx rule. 5xx and 429 errors are still retried up to `MAX_RETRY_FAILURE_COUNT`. The function is exported so it can be unit-tested, and `data/storage/buckets-query.test.ts` covers the new behaviour. Checks run: - `pnpm exec vitest run data/storage/buckets-query.test.ts` (3 passed) - `pnpm turbo run typecheck --filter='...[origin/master]'` - `pnpm turbo run lint --filter='[origin/master]'` - prettier `--check` on the changed files ## Review instructions 1. Open Storage > Files (`/project/<ref>/storage/files`) for a project whose buckets request returns a 4xx (for example a 402 for a restricted project). The "Failed to retrieve buckets" error with the API message shows after one request, with no long loading state. 2. Open the same page for a healthy project. Buckets load and list as before. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) [FE-4925](https://linear.app/supabase/issue/FE-4925/storage-loads-endlessly-without-showing-error-message-if-organization) Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com> |
||
|
|
8bebf8206e |
fix(logs): retain loaded history on refresh DEBUG-233 (#51598)
Preserve loaded log history during refresh, bound refresh requests, and stop automatic polling when Live is paused. |
||
|
|
5152899fac |
Joshenlim/fe 4720 cmd k support searching for functions (#52751)
## Context Building off from [here](https://github.com/supabase/supabase/pull/52678) to make Cmd+K resource-aware so finding and inspecting anything in a project doesn't depend on knowing where it lives in the dashboard. Specifically looking into database entities for now - end state would be that you could search for a table name for example, and Cmd K will pull up everything related to that table for you to skim (e.g Policies, Functions, Triggers, etc). Changes in this PR sets up searching for **database functions**. <img width="607" height="531" alt="image" src="https://github.com/user-attachments/assets/b4a2cd15-9874-4e80-80d4-d343d8c70fc3" /> ## Performance Ran a Claude session to benchmark `getSearchEntitiesSql` against the version on master (tables and policies only), on the same synthetic catalog: - 12,000 tables (36,651 `pg_class`), 6,001 policies, 27,258 `pg_proc` (12,000 user + 12,000 extension-owned functions), 290,915 `pg_depend`. - Median of 5 runs, `EXPLAIN ANALYZE`, local Postgres (warm cache). | Search | Matches | master | this PR | |---|---|---|---| | `t_1` | ~1/9 of tables | 12ms | 23ms | | `p_1` | broad policy-name match | 13ms | 25ms | | `fn_1` | user + extension functions | 8ms | 23ms | | `fn_` | every function | 8ms | 29ms | | `stress.fn_1` | schema-qualified | 10ms | 30ms | | `zzz` | nothing | 9ms | 22ms | - Adding functions costs +11 to +21ms at this scale - Most of it is fixed (+13ms even for a query that matches nothing): one pass over `pg_proc`, plus building the set of extension-owned functions. It doesn't grow with the number of matches. ## To test - [ ] Search a table name: Tables first, then policies, and functions - [ ] Search a function name: it appears under Functions and opens the editor panel in database/functions - [ ] Function outside public: schema filter switches and the function opens |
||
|
|
b3dd6612d7 |
feat(studio): classify errors with fault, reason, and per-tag Sentry sampling (#52730)
Follows #52707 (rename `ResponseError` to `StudioError`). Resolves FE-4772. ## What Introduces the error core for Studio error classification. - **Tagged errors.** `lib/errors/studio-errors.ts` defines `Data.TaggedError` classes (`RequestAborted`, `NetworkUnreachable`, `MalformedResponse`, `PlatformError`, `UnclassifiedApiError`, `DbConnectionTimeout`, `UnexpectedError`). Each carries `fault`, `reason`, `classifiedBy` (`rule` or `default`), `retryable`, and `service`. `StudioError` is the union type; use `isStudioError` instead of `instanceof`. - **Two classifiers** in `data/error-classification.ts`: - `classifyResponseError` is only for errors from an API response: known message patterns first, then defaults by status (5xx `PlatformError`, 4xx `UnclassifiedApiError`, no status `UnexpectedError`). - `classifyError` is for everything else: aborts, browser fetch failures (matched by message, so ordinary `TypeError` bugs stay `UnexpectedError`), and unexpected errors. - `handleError` picks between them, reports, and rethrows the same instance so React Query receives the classified error. - **Routing and sampling.** `lib/errors/error-routing.ts` maps every tag to a Sentry sample rate (`SAMPLE_NEVER`, `SAMPLE_OTHER`, `SAMPLE_OWNED`, `SAMPLE_ALWAYS`). `reportStudioError` tags events with `sample_rate`, and `beforeSend` applies it. `alwaysCapture` reports at rate 1. The global Sentry error `sampleRate` stays unset so the rates don't multiply. - **Network failures.** A fetch failure is a `user` fault with reason `offline` when the browser reports being offline, and a `platform` fault otherwise. - **Hand-built errors.** Call sites that wrapped caught exceptions or made up status codes now use `classifyError` or a specific class instead of `classifyResponseError`. ## Behavior changes - Errors that previously went unreported, including unexpected errors with a message, are now reported to Sentry at their routed sample rate. - `handleError` no longer logs the stack with `console.error`. - `MalformedResponse` is defined but not produced yet; a follow-up adds the empty-body check. ## Testing - Unit tests for classification, routing, reporting, and the `beforeSend` sampling helper. - `pnpm vitest run data lib components/interfaces/ErrorHandling`, typecheck, lint ratchet, and knip pass locally. |
||
|
|
bef73a722c |
feat(studio): gate storage, cron, and realtime key consumers on grants (#52728)
Part 4 of 4 in a stack for [FE-4694](https://linear.app/supabase/issue/FE-4694/pilot-split-api-keys-queries-and-add-first-refinement-reveal-variant). Based on #52727. ## Stack 1. #52723 Reveal refinement and split api-keys queries 2. #52724 API keys settings UI and command menu 3. #52727 Database and edge functions consumers that reveal secret keys 4. 👉 Storage, cron, and Realtime consumers; remove the transitional reveal path ## Changes Moves the remaining consumers that need secret keys onto the `reveal` grant with `revealedApiKeysQueryOptions`, replacing their V2 permission checks: - Analytics bucket configuration details and the update catalog token dialog - The Iceberg wrapper create mutation. Its V2 check only covered `api_gateway_keys_secret_read`, which didn't match the endpoint's requirement. Without keys it used to save a placeholder as the vault token; it now throws unless the grant is granted, and returns the grant so callers can explain why. The bucket create form disables Create and the missing-wrapper callout disables "Install wrapper", both showing `ApiKeysAccessNote`. The `storage_config_write` check is unchanged. - Cron job HTTP headers (edge function variant) `RealtimeTokensPopover` only reads the anon and publishable keys, so it moves to the plain grant and `apiKeysQueryOptions` instead of requesting revealed keys. With no `reveal: true` callers left, the transitional `useAPIKeysQuery` / `useAPIKeys` hooks drop their reveal path and only mint a plain grant. They remain for the publishable-only consumers until FE-4731. ## Testing - `iceberg-wrapper-create-mutation.platform.test.tsx`: `mutateAsync` throws without the reveal grant and makes no credentials request; the granted case exposes the grant. - `BucketCallouts.platform.test.tsx`: "Install wrapper" is enabled when granted, and disabled with the note when denied or with an error when the permission check fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
676ea140ef |
refactor(studio): align OAuth role validation failure types with the API (#52532)
## Problem
The scoped OAuth consent screen is still mock-backed, and its types for
`role_validation_failed` responses don't match what the platform API
will return. The API reports only the role level (`owner`,
`administrator`, `developer`, `read-only` or `no-access`) in each
failure, not the full role object, and project failures carry no `name`.
## Solution
- `OAuthScopeValidationResult` uses `{ name: 'owner' | 'administrator' |
'developer' | 'read-only' | 'no-access' }` for `role` in all three
`scope_target` variants, and project failures drop `name`.
- The mock approval and preflight responses build that shape from the
mock org roles.
- `types.test.ts` fixtures follow the new shape.
The consent screen only reads `ref` from project failures, so there is
no UI change.
The types are hand-written until the API change that introduces this
shape lands and `api-types` is regenerated.
Verification: `vitest run data/oauth-apps
components/interfaces/Organization/OAuthApps` (115 passed). `tsc
--noEmit` reports one error in `packages/ui-patterns`, which also occurs
without this change.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
|
||
|
|
d727bb0081 |
feat(studio): add reveal refinement for api-keys and split queries (#52723)
Part 1 of 4 in a stack for [FE-4694](https://linear.app/supabase/issue/FE-4694/pilot-split-api-keys-queries-and-add-first-refinement-reveal-variant). Later PRs migrate the api-keys consumers onto grants. ## Stack 1. 👉 Reveal refinement and split api-keys queries 2. #52724 API keys settings UI and command menu 3. #52727 Database and edge functions consumers that reveal secret keys 4. #52728 Storage, cron, and Realtime consumers; remove the transitional reveal path ## Changes - Adds a `reveal` variant for `GET /v1/projects/{ref}/api-keys` in `lib/fga-refinements.ts`. It requires `api_gateway_keys_secret_read` on top of the base annotation, and owns the `reveal` query param: the fetch wrapper sets it to `'true'` for a reveal grant and `'false'` otherwise (including `unguarded`), so passing `reveal` by hand is a type error. - Splits the query into `apiKeysQueryOptions` (plain grant) and `revealedApiKeysQueryOptions` (reveal grant). Both use `skipToken` without a grant, and the grant stays out of the query key. - `useAPIKeysQuery` and `useAPIKeys` stay as deprecated transitional hooks that mint the matching grant with `useGrant`. They can't use `unguarded.migrating`: with `reveal` owned by the wrapper, that would silently return unrevealed keys to consumers that need secrets. - Marks the variant type parameter `const` in `getGrant`, `useGrant`, `ensureGrant`, and `testGrant`. Adding a second refinement with variants widened inference of the branch variants to a union. - Adds `tests/lib/project-grant-mocks.ts` for component tests that need `useGrant` to resolve, and updates tests that partially mocked the V2 permissions hook. ## Testing Adds the type and runtime tests deferred from FE-4689 to `data/guarded-fetch.test.ts`: type equality with the raw client for plain and reveal grants, `reveal` rejected as a caller-supplied param, a reveal grant rejected on an endpoint without that variant, brand invariance, `guardMethod` setting `reveal` from the grant, and `assertGrant` throwing on an unknown variant. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
2b55f7db9a |
Joshenlim/fe 4719 cmd k support searching for policies (#52678)
## Context Continue to build off from [here](https://github.com/supabase/supabase/pull/52205) to make Cmd+K resource-aware so finding and inspecting anything in a project doesn't depend on knowing where it lives in the dashboard. Specifically looking into database entities for now - end state would be that you could search for a table name for example, and Cmd K will pull up everything related to that table for you to skim (e.g Policies, Functions, Triggers, etc). Changes in this PR sets up searching for RLS policies. <img width="609" height="525" alt="image" src="https://github.com/user-attachments/assets/212a430a-314d-48c4-a27c-2f9bb06e8457" /> Policies are matched on, in priority, its name and the target table. ## Performance checking Just ran a check with Claude just to make sure that the added SQL doesn't cause any performance degradation on the database. Plan guard passes at 12,000 tables, under its 500ms budget. Also benchmarked locally with a 3-character query matching every policy, results look good so should be alright: | Catalog | Worst-case search | No-match baseline | |---|---|---| | 36k policies | ~52–64ms | ~16ms | | 120k policies | ~118–134ms | ~63ms | ## To test - [x] Search a table name: Tables first, then its policies, under Policies - [x] Search a policy name: it appears under Policies and opens the editor panel in database/policies - [x] Policy outside `public`: schema filter switches and the policy opens |
||
|
|
0b9e8bdea4 |
Joshenlim/fe 4882 make the new integrations UI the default (#52683)
## Context Makes the one-click integrations feature preview the new default + cleans up all the old integrations code that's no longer used with this change ## To test - [ ] Verify that the project integrations page is using the new UI |
||
|
|
df742bdb3b |
refactor(studio): rename ResponseError to StudioError (#52707)
## What
Moves the `ResponseError` class (`types/base.ts`) and the classified
error classes (`types/api-errors.ts`) into
`lib/errors/studio-errors.ts`, and renames `ResponseError` to
`StudioError`.
## Why
Studio's error classification is being expanded to cover errors that
don't come from API responses (thrown network failures, aborted
requests, unexpected client errors). The API-specific name and location
no longer fit. Landing the rename on its own keeps the follow-up PR,
which introduces the classified error model, small and reviewable.
## Notes for reviewers
- Mechanical change, no behavior change. Most of the diff is a one-line
import change per file plus import re-sorting by Prettier.
- Files that only use the type now use `import type { StudioError }`.
- `ResponseError` is no longer re-exported from `@/types`; there are no
compatibility shims at the old paths.
- Unrelated identifiers like `QueryResponseError` and
`parseResponseErrors` are unchanged.
|
||
|
|
53e2c4f1d1 |
[FE-4809] fix(studio): group HA topology by shardRef (#52545)
Update HA topology grouping for the Multigres JSON field rename from `shardKey` to `shardRef`, so separate shards retain their own primaries and replicas. **Changed:** - Normalize pooler responses to `shardRef`, falling back to legacy `shardKey` and preferring `shardRef` when both exist. - Use `shardRef` in the topology selector and shard grouping. **Added:** - Regression coverage from response parsing through diagram node/edge generation for new, legacy, mixed, and conflicting key formats, plus omitted shard identity fields. Addresses https://linear.app/supabase/issue/FE-4809/update-studio-ha-topology-grouping-to-use-shardref ## To test - Open Settings → Infrastructure on a multi-shard HA project returning `shardRef`. Confirm one group per shard, each primary shown as Primary Database, and replicas connected only to their own shard's primary. - Check the same topology on Database → Pipelines. - Confirm legacy `shardKey` responses still render correctly and single-shard projects remain unchanged. ## Validation - Passed: 33 targeted utility tests, ESLint on all changed files, Studio TypeScript check, and diff whitespace checks. - Local browser: login and non-HA infrastructure passed. HA grouping remains unverified because local poolers/gateways endpoints returned 404; browser response mocking was blocked by cross-origin/CORS limitations. - Upstream multigres/multigres#1608 merged October 29; deployment of the renamed field remains unconfirmed. Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com> Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> |
||
|
|
9b7cbd1803 |
feat(studio): migrate branches to FGA grants with production/development variants (#52331)
## Problem Branch actions in Studio were guarded by hand-written permission checks (`useAsyncCheckPermissionsV2(FGA_PERMISSIONS.PROJECT.BRANCHING_*)`, plus one legacy `useAsyncCheckPermissions` in `Branch.Commands.tsx`) that weren't tied to the endpoints they protect. Every branches request in `data/branches` was marked `unguarded.migrating`. This is the pilot migration for endpoint-bound FGA grants. Resolves [FE-4693](https://linear.app/supabase/issue/FE-4693/pilot-migrate-branches-to-grants-8-endpoints-createbranchmodal). ## Solution ### Data layer * `data/branches` has no `unguarded.migrating` left (was 10). * The list, detail, and diff queries are now `branchesQueryOptions`, `branchQueryOptions`, and `branchDiffQueryOptions`. They take a grant, use `skipToken` without one, and keep the grant out of the query key. * Mutations take the grant in their variables. The merge mutation also takes `diffGrant`, because it reads the diff before merging. ### Production and development variants The backend doesn't treat development and production branching permissions as interchangeable: * Actions on a single branch (`/v1/branches/{branch_id_or_ref}` and its diff, merge, push, reset, and restore) need the production permission for the default branch and the development permission for preview branches. * Creating a default branch or a branch with data needs production create. To model this, `lib/fga-refinements.ts` gets its first entries: * The 8 single-branch endpoints have `production` and `development` variants. A new `variantRequired` flag makes the fetch wrapper reject a grant without a variant, at compile time and in `assertGrant`. * `POST /v1/projects/{ref}/branches` has a `production` variant. `assertGrant` requires it when the body sets `is_default` or `with_data`. * `useBranchGrant(endpoint, { projectRef, isDefault })` picks the variant from the branch's `is_default`. It stays `loading` until the branch is known. * `GrantForVariants<M, P>` types a grant for any of an endpoint's variants. ### UI * The old checks are replaced with grants in `CreateBranchButton`, `CreateBranchModal`, `Overview`, `DeleteBranchPanel`, `DeleteBranchModal`, the branches and merge-requests pages, and `Branch.Commands.tsx`. * Grants are evaluated against the parent project, where branch permissions live. The scope is passed explicitly, because `/v1/branches/*` paths don't include the project. * Pages that are mainly about branches show `NoPermission` when the grant is denied and `AlertError` when the permission check fails. Action buttons are disabled with a tooltip. Places that use the branch list incidentally (nav, project home, usage) treat a denied grant as "no branches" instead of loading forever. * "Include data" in `CreateBranchModal` is disabled without production create. It previously failed after submitting. * `OutOfDateNotice`'s "Update branch" is disabled without the push grant. It previously did nothing. * The GitHub integration form blocks saving without the production-branch grant. Previously the connection was saved while the branch request failed, and a repo change deleted the old connection first. ### Where the old checks differed from the backend * **Too strict:** the branches and merge-requests pages required development read, and the create button required development create. The backend accepts development or production for both. * **Wrong for the default branch:** single-branch actions always checked development permissions, or production write for the main branch menu, regardless of which branch was targeted. * **Missing:** reset and "Switch to persistent" in `Overview` had no check. * **Legacy check:** `Branch.Commands.tsx` used the legacy `CREATE preview_branches` check. `BranchingPITRNotice` is unchanged: its check guards a subscription update, not a branches request. ### Other changes * The two new query options use an `eslint-disable` for `@tanstack/query/exhaustive-deps`, because grants stay out of query keys. A separate PR upgrades the plugin and allowlists `grant`, after which these can be removed. * `upsertMigration` in the merge mutation still uses `unguarded.migrating`. It belongs to the database-migrations domain. ## Testing * New component tests for `CreateBranchButton`, `DeleteBranchPanel`, the branches page, and `GitHubIntegrationConnectionForm` cover granted, denied, and error states. * New `useBranchGrant` tests: default vs. preview branch, and loading until the branch is known. * `guarded-fetch.test.ts` covers required variants (types and runtime) and the production variant for default and data branches. * Shared fixtures are in `tests/lib/branch-test-utils.ts`. * Studio typecheck passes, affected suites pass, the ESLint ratchet is stable, and knip is clean. |
||
|
|
b9a2422deb |
fix(pipelines): Fix data loading issue in Pipelines (#52642)
Co-authored-by: Joshen Lim <joshenlimek@gmail.com> |
||
|
|
5dfd86d35c |
fix: regressed studio typecheck performance (#52677)
Heads up: Generated with Claude Opus 5.5 CheckedInit made TypeScript infer each call's init through conditional and Omit types over the full API paths, at every typed get/post/put/ patch/del call site. A cold `tsc --noEmit` spent 92s type-checking and peaked at 17 GB of memory. CheckedUrl already rejects missing, mismatched, and unexpected grants, so the init check was redundant. Remove CheckedInit and ParseAsContext (which only worked around CheckedInit breaking parseAs inference) and type init the way openapi-fetch does. Cold check time: 92s -> 5.4s. Instantiations: 34.9M -> 16.4M. Peak memory: 17.3 GB -> 5.5 GB. All guarded-fetch type tests still fail for the same reasons. |
||
|
|
90c3e57e05 | feat(studio): realtime health advisors (#52535) | ||
|
|
8be85ad4ad |
feat(studio): guard branch update and push with FGA grants (#52377)
Part 6 of 7 in a stack that splits #52331 into reviewable pieces. Resolves part of [FE-4693](https://linear.app/supabase/issue/FE-4693/pilot-migrate-branches-to-grants-8-endpoints-createbranchmodal). There are no functional changes beyond #52331, and the top of the stack is identical to it. See #52331 for the full rationale. ## Stack 1. #52372 Grant infra for branch variants 2. #52373 Branches list query 3. #52374 Page gates on the list grant 4. #52375 Branch creation 5. #52376 Branch read, delete, reset, and restore 6. 👉 #52377 Branch update and push 7. #52378 Branch diff and merge ## Changes The update and push mutations take grants. `Overview` (including "Switch to persistent", which previously had no check), `EditBranchModal`, `SwitchToPreviewModal`, `MergeRequestButton`, the merge-requests page, and the merge page use `useBranchGrant`. The "Update branch" button in `OutOfDateNotice` is disabled without push; previously it did nothing. The GitHub integration form blocks saving without the production-branch grant. Previously the connection was saved even when the branch request failed. ## Testing New `GitHubIntegrationConnectionForm` test. |
||
|
|
5ff6930c2a |
feat(studio): send role passwords as precomputed SCRAM-SHA-256 verifiers (#52544)
## What kind of change does this PR introduce? Feature. ## What is the current behavior? Role passwords are sent as plaintext in the SQL (`create role ... password '...'` and `alter role ... password '...'`), so they can end up in Postgres logs. ## What is the new behavior? ASCII role passwords are hashed in the browser with Web Crypto and sent as a precomputed `SCRAM-SHA-256$...` verifier. Postgres stores a verifier as given, so the plaintext no longer appears in the SQL or the server logs. This applies to every flow that sets a role password, because they all go through the role create and update mutations. Non-ASCII passwords are still sent as plaintext. Postgres normalizes passwords with SASLprep before hashing, and the browser code doesn't apply it, so a verifier built from the raw text could stop the role from logging in. For ASCII, SASLprep changes nothing, so the verifier always matches. The `saslprep` package can't be used here because it reads its table with `fs.readFileSync` at import time. Covering non-ASCII passwords is a follow-up, most likely a server-side API. Studio also falls back to plaintext when `crypto.subtle` isn't available, which browsers only expose in secure contexts. This keeps setting a password working on self-hosted Studio served over plain HTTP. ## Known limitations - The verifier is built with 4096 iterations, the Postgres default. If a project sets `scram_iterations` higher, these roles keep 4096, because Postgres stores a supplied verifier as given. Reading the setting first needs an extra query and a grant for it, so it's left for the follow-up below. - Non-ASCII passwords, and Studio over plain HTTP, still send plaintext. - The follow-up is a server-side path that sets the password without it going through the SQL, which would honor the server's own settings and cover these cases. A verifier isn't secret (it can be attacked offline), but it is a clear improvement over plaintext. ## Testing - Unit tests compare the helper with an independent `node:crypto` implementation, and check that ASCII passwords become verifiers and non-ASCII passwords pass through unchanged. - I also checked against a real Postgres: roles given these verifiers log in with the plaintext password and reject a wrong one. - The `CreateRolePanel` test now expects a verifier and no plaintext in the SQL. Resolves FE-4822. |
||
|
|
4810bbcfdf |
feat(studio): guard branch read, delete, reset, and restore with FGA grants (#52376)
Part 5 of 7 in a stack that splits #52331 into reviewable pieces. Resolves part of [FE-4693](https://linear.app/supabase/issue/FE-4693/pilot-migrate-branches-to-grants-8-endpoints-createbranchmodal). There are no functional changes beyond #52331, and the top of the stack is identical to it. See #52331 for the full rationale. ## Stack 1. #52372 Grant infra for branch variants 2. #52373 Branches list query 3. #52374 Page gates on the list grant 4. #52375 Branch creation 5. 👉 #52376 Branch read, delete, reset, and restore 6. #52377 Branch update and push 7. #52378 Branch diff and merge ## Changes `useBranchQuery` becomes `branchQueryOptions`. The delete, reset, and restore mutations take grants. `DeleteBranchModal`, `DeleteBranchPanel`, and the relevant `Overview` actions use `useBranchGrant`, which picks production for the default branch and development for preview branches. Reset previously had no check. ## Testing New `DeleteBranchPanel` test. |
||
|
|
be28b2517f |
fix(logs): correlate request and trace IDs DEBUG-260 (#52514)
Correlate related log timelines using request and trace IDs, and improve the Timeline empty state. Fixes DEBUG-260. |
||
|
|
31c9854c2a |
chore: update api types (#52618)
Fixes API-types as per latest develop - pending prod deployment today to clear out the failing action that checks against prod types |