Commit Graph
1526 Commits
Author SHA1 Message Date
alexisintech d903f1f267 [create-pull-request] automated change 2026-12-03 23:10:41 +00:00
kemal.earth 1ef66de793 feat(studio): add trace span route query (#54391)
## Problem

The Unified Logs trace tab needs the spans for a request's trace.
Nothing in Studio fetches them yet.

Part 2 of 3. Data layer only — the tab that consumes this lands in part
3.

## Solution

Adds `unifiedLogTraceSpansQueryOptions`, fetching `GET
/v2/projects/{ref}/analytics/traces/{trace_id}`, plus the `traceSpans`
query key.

Two choices worth flagging:

**Fetched and parsed directly, not through the typed client.** The route
is live in the v2 OpenAPI spec, but it isn't in the committed
`api-types` — and `get()` is typed off the generated `paths`, so it
can't address a route that isn't there. Getting it there means
regenerating `api-types`, which currently drags in a large amount of
unrelated production drift and breaks Studio's typecheck in three
places. That's worth doing on its own, not as a side effect of this. So
the query goes through `fetchHandler` and parses the response with zod,
following the `platform-apps/platform-app-query.ts` precedent.

The parse likely stays even after a regen: the spec declares no
`additionalProperties` on a span's `attributes`, so the generated type
would describe only the seven known keys and none of the OTel attributes
the trace view actually reads (`http.route`, `url.full`, `db.*`, and
whatever else a service reports). `.passthrough()` keeps them. It also
means the parse is load-bearing — it's the only thing validating the
response shape at runtime, so a backend change surfaces as an error at
the boundary rather than a build failure.

**A temporary knip entry.** Nothing imports the query until part 3, so
knip reports it as an unused file and fails the build. Per
`apps/studio/AGENTS.md`, it's listed in `knip.jsonc` with a `used from
#NNN` comment; part 3 deletes that entry when it adds the importer.

## Review instructions

1. Check the zod schema against the live spec — it should match field
for field:
   ```bash
   curl -s https://api.supabase.com/api/v2-json \
     | jq '.components.schemas.ListSpansResponse_Output'
   ```
2. Confirm the knip entry in `knip.jsonc` is marked temporary and points
at part 3.
3. Run `pnpm knip --workspace apps/studio` and confirm it passes.

## 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)
2026-12-03 14:38:33 +00:00
kemal.earth 6d8af8e950 chore(api-types): regenerate types from production specs (#54472)
## Problem

`packages/api-types` has drifted from the production OpenAPI specs.
#54394 regenerated them but was reverted in #54404, because the API had
rolled out ahead of its OpenFGA model. That has since been fixed on the
backend, so the regen can land.

...plus I need the new spec for #54391 and didn't want to blow up my
branch.

## Solution

Regenerated with `pnpm --filter=api-types codegen:prod` (production
specs, not the localhost `codegen`), plus the type fixes the new specs
require:

- `platform-webhooks-fetchers.ts` — `page` is now a deep object in the
spec, so the query params move from `page[limit]` keys to a nested
`page` object with a `deepObject` serializer.
- `InvoicesSettings.test.tsx` — four newly-required invoice fields in
the mock.
- `packages/shared-data` — `@supabase/shared-types` 0.1.98 → 0.1.102,
matching `apps/studio`.

Notable additions: the `environment_*` FGA scopes and `GET
/v2/projects/{ref}/analytics/traces/{trace_id}`.

## Review instructions

1. `pnpm --filter=api-types run verify-production-types` — passes.
2. `pnpm typecheck` and `pnpm --filter=studio test` — pass.
3. Only the three non-generated files need reading; the rest is
generated output.

Note: `verify-production-api-types` was removed from the required checks
during the #54394 incident and hasn't been restored. Worth putting back
after this merges.
2026-12-02 13:51:52 +00:00
Danny WhiteandJoshen Lim be27ad8cf5 feat(studio): show apps and confirm token access changes (#53917)
> [!WARNING]
> This PR relies on #53705 being merged first.

## Problem

Project admins need to see authorised apps before changing token access.
[DEPR-734](https://linear.app/supabase/issue/DEPR-734)

## Solution

- Show Apps below Members only when authorised apps exist; hide the
section while loading or empty, and retain verification errors.
- Show access levels and links to each app’s access sheet.
- Include members and authorised apps in toggle confirmations; wait for
complete counts and offer retry on errors.

| After |
| --- |
| <img width="725" height="560" alt="CleanShot 2026-12-02 at 14 44 13"
src="https://github.com/user-attachments/assets/6f033b2f-a8b4-4a64-824f-ef0cc270ff6c"
/> |
| No authorised apps (no empty state) |
| <img width="728" height="773" alt="CleanShot 2026-12-02 at 14 11 31"
src="https://github.com/user-attachments/assets/76b31461-abca-4f9a-b76d-bb664093dd67"
/> |
| Loading error |
| <img width="727" height="749" alt="CleanShot 2026-12-02 at 14 38 34"
src="https://github.com/user-attachments/assets/0722002c-a5cf-4877-b00b-15f9e4a6524c"
/> |
| 1× authorised app |
| <img width="418" height="222" alt="CleanShot 2026-12-02 at 14 39 27"
src="https://github.com/user-attachments/assets/db5cc89a-2099-4a6f-969c-b4e2c38ac972"
/> |
| Disabling token access whilst 1× app is relying on it |
| <img width="424" height="387" alt="CleanShot 2026-12-02 at 14 39 58"
src="https://github.com/user-attachments/assets/e15c1227-8190-42f4-876b-5f55a321848b"
/> |
| Re-enabling token access which will immediately restore access for N
members and apps |


## Review instructions

1. Open the [staging
preview](https://studio-staging-git-dnywh-depr-734-temporary-acc-b81819-supabase.vercel.app/dashboard),
select a project you administer, and open **Database → Settings**.
Enable database token access in **Feature previews**, plus `jitDbAccess`
and `enableScopedOAuthManage` in the dev toolbar’s **Flags** tab if
needed.
2. Open DevTools → **Console**, paste the setup below and run it.
Navigate to another Studio page (possibly outside of Database) and back
to **Database → Settings**, without reloading. Check **Test Partner
App** appears under Apps with **Read and write** access.
3. Turn token access off. Check the confirmation includes the app, then
choose **Cancel**.
4. Run `tokenAccessReview.state = 'disabled'` in Console, then navigate
away and back. Turn token access on, expand **Who will regain access?**,
check the app is listed, then choose **Cancel**.
5. Run `tokenAccessReview.state = 'enabled'; tokenAccessReview.fail =
true`, then navigate away and back. Check the Apps error disables the
toggle. Run `tokenAccessReview.fail = false` and choose **Retry apps**
to recover.
6. Run `tokenAccessReview.apps = false`, then navigate outside Database
and back. Check Apps is hidden once loaded. Reload to remove the setup.

The setup mocks GET responses only, requires no app authorisation, and
does not change saved access. Use **Cancel** in both confirmations. Do
not reload between steps; reloading removes the setup. Network’s
Response tab does not show these browser-generated responses.

<details>
<summary>Console setup</summary>

```js
(() => {
  if (window.tokenAccessReview) throw new Error('Review setup is already active. Reload to reset it.')
  const projectRef = location.pathname.match(/\/project\/([^/]+)/)?.[1]
  if (!projectRef) throw new Error('Open a project’s Database Settings first.')
  const appId = '75e64165-b74e-432f-bb70-80d6ae432f06'
  const grantId = 'review-org-grant'
  const scopes = ['database_token_access:write']
  const originalFetch = window.fetch
  const review = window.tokenAccessReview = { state: 'enabled', apps: true, fail: false }
  const approvals = /\/platform\/organizations\/[^/]+\/oauth\/approvals$/
  const grants = new RegExp(`/platform/organizations/[^/]+/oauth/approvals/${appId}/grants$`)
  const page = (data) => Response.json({ data, links: { next: null, prev: null } })
  window.fetch = function (input, init) {
    const url = new URL(input instanceof Request ? input.url : input, location.href)
    const method = init?.method ?? (input instanceof Request ? input.method : 'GET')
    if (method.toUpperCase() === 'GET') {
      if (url.pathname.endsWith(`/v1/projects/${projectRef}/jit-access`)) {
        return Promise.resolve(Response.json({ state: review.state, appliedSuccessfully: true }))
      }
      if (approvals.test(url.pathname)) {
        return Promise.resolve(page(review.apps ? [{
          id: appId, type: 'oauth_app', attributes: {
            app: { name: 'Test Partner App', icon: null, created_by: null },
            last_approved_at: '', target: 'organization',
            org_grant: { grant_id: grantId, approved_scopes: scopes, approved_at: '' },
          },
        }] : []))
      }
      if (grants.test(url.pathname)) {
        if (review.fail) return Promise.resolve(Response.json({ message: 'Review: apps unavailable' }, { status: 500 }))
        return Promise.resolve(page([{
          id: grantId, type: 'oauth_grant', attributes: {
            kind: 'organization_bound', user: null, approved_at: '', approved_scopes: scopes,
            projects: [{ ref: projectRef, name: 'Review project' }],
          },
        }]))
      }
    }
    return originalFetch.call(this, input, init)
  }
})()
```

</details>

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-12-02 19:55:19 +07:00
Danny WhiteandJoshen Lim 4dbb966b2e feat(studio): show Trusted Partner access on OAuth consent (#53583)
> [!WARNING]
> Live readiness checks require
[CTRL-2277](https://linear.app/supabase/issue/CTRL-2277) in the target
environment; production deployment is pending.

## Problem

Trusted Partner consent must explain direct database access and project
blockers before authorisation.
[DEPR-732](https://linear.app/supabase/issue/DEPR-732)

## Solution

- Show Direct database access alongside the requested permissions.
- Check selected projects, or every project page for organisation-wide
grants.
- Separate blocking issues from SSL notices; block authorisation during
loading or errors and offer retry.

| After |
| --- |
| <img width="1280" height="1323" alt="Authorize API Access Supabase"
src="https://github.com/user-attachments/assets/adb6367a-bace-4b62-81b5-68ba4c11396c"
/> |
| Consent screen with Direct database access (previously “Table data”)
and Database management |
| <img width="1280" height="1323" alt="Authorize API Access Supabase"
src="https://github.com/user-attachments/assets/0c35900c-1059-49cd-b1c5-4e0cf5441b9b"
/> |
| Selected-project blockers and the separate SSL notice |
| <img width="1280" height="1323" alt="95741"
src="https://github.com/user-attachments/assets/1fbef4f0-0433-4c93-b390-84d210dfb665"
/> |
| Organisation-wide blockers _without_ project-removal actions |

## Review instructions

1. Open the [staging consent
screen](https://studio-staging-git-dnywh-depr-732-trusted-partn-f24cfb-supabase.vercel.app/dashboard/authorize?auth_id=11666aa8-7f7e-4705-b33a-981903fd682e).
Enable `enableScopedOAuthConsent` in the dev toolbar’s **Flags** tab if
needed.
2. Open Chrome DevTools → **Network** and reload. Select the **GET**
request ending in `/platform/oauth/authorizations/{id}`.
3. Right-click that request → **Override content**. Choose a local
folder and click **Allow**. Add `database_token_access:read` and
`database_token_access:write` to `scopes`. Use only the read scope to
check read-only access. Keep every other field, save with
**Cmd/Ctrl+S**, then reload with DevTools open.
4. Select projects. Override each **GET** request ending in
`/platform/organizations/{slug}/oauth/authorizations/{id}/projects/{ref}/database-access`.
Use `{"issues":[],"enables_ssl":false}` for ready projects, then
`{"issues":[],"enables_ssl":true}` for an SSL notice. Save and reload
after each change. Check Direct database access and Database management
are separate, and SSL alone allows authorisation.
5. Change a readiness response to
`{"issues":["postgres_upgrade_required","platform_unsupported"],"enables_ssl":true}`.
Save and reload. Check blockers prevent authorisation, SSL stays
separate, and removing a blocked project clears its blockers.
6. Set `project_scoping_mode: false` in the authorisation override. Save
and reload. Check any blocked project prevents organisation-wide
authorisation, with no project-removal actions.
7. Block a database-access request in Network and reload. Check
authorisation stays disabled. Unblock it and choose **Retry checks**.
8. For a returning app, override `existing_grant.approved_scopes` in the
request ending in `/preflight`. Save and reload. Check added, removed
and unchanged permissions.
9. Disable **Sources → Overrides → Enable Local Overrides**. Repeat
ready and blocked project checks with a real staging authorisation
before approving live readiness behaviour.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-12-02 16:19:30 +07:00
Danny WhiteandJoshen Lim 05cbf8ca50 feat(studio): show Trusted Partner access in Authorized Apps (#53705)
## Problem

Organisation admins need to see authorised apps’ direct database access.
[DEPR-731](https://linear.app/supabase/issue/DEPR-731)

## Solution

- Show the approved direct-access level in Authorized apps.
- Show permissions and project coverage in **View access**.

| After |
| --- |
| <img width="1280" height="813" alt="OAuth Apps Organization Settings
Basket Supabase"
src="https://github.com/user-attachments/assets/d2bbc682-6e6f-462f-b5c2-3a2a8ff813ba"
/> |
| Authorized apps list showing read-only direct access |
| <img width="1280" height="813" alt="OAuth Apps Organization Settings
Basket Supabase (4)"
src="https://github.com/user-attachments/assets/24506547-461a-44e0-880f-6ade23fd734c"
/> |
| Authorized apps list showing read-write direct access |
| <img width="1280" height="813" alt="OAuth Apps Organization Settings
Basket Supabase (1)"
src="https://github.com/user-attachments/assets/53ac2662-9fb7-4cfc-b118-31ef5778b339"
/> |
| View access sheet with permission groups and project coverage |
| <img width="1280" height="813" alt="OAuth Apps Organization Settings
Basket Supabase (3)"
src="https://github.com/user-attachments/assets/a21cefa7-c656-4b5c-bb0c-075c724350f9"
/> |
| View access sheet with permission groups and project coverage |
| <img width="424" height="297" alt="CleanShot 2026-12-02 at 15 09 39"
src="https://github.com/user-attachments/assets/e1f83068-21a8-43c4-9ca8-dcf6a3164b01"
/> |
| Added second paragraph for revoking access to apps with direct
database access. This “existing connections will close shortly” is only
accurate one CTRL-2141 merges, as discussed
[here](https://github.com/supabase/supabase/pull/53705/changes#r4764576735).
|

## Review instructions

1. Open the [staging
preview](https://studio-staging-git-dnywh-depr-731-authorized-apps-supabase.vercel.app/dashboard),
select a test organisation and open **Apps**
(`/dashboard/org/{slug}/apps`). Enable `enableScopedOAuthManage` in the
Studio dev toolbar’s **Flags** tab if needed.
2. Open Chrome DevTools → **Network** and reload. Select the **GET**
request ending in `/platform/organizations/{slug}/oauth/approvals`.
3. Right-click that request → **Override content**. Choose a local
folder and click **Allow**. For an existing organisation-bound app, add
`database_token_access:read` to `attributes.org_grant.approved_scopes`.
Keep every other field, save with **Cmd/Ctrl+S**, then reload with
DevTools open.
4. Open the app’s **View access**. Override the **GET** request ending
in `/platform/organizations/{slug}/oauth/approvals/{app_id}/grants`. Add
the same scope to the matching grant’s `attributes.approved_scopes`.
Save and reload.
5. Check read-only direct access in the list and access sheet. Change
the scope to `database_token_access:write` in both overrides, save and
reload. Check read-write access and compare it with a standard app.
6. Compare the grants response’s existing `attributes.projects` list
with `null` for all projects. Save and reload after each change. Check
permission groups, project coverage and the app ID in **View access**.
7. Open **Revoke access**, check the existing OAuth access explanation,
then choose **Cancel**.
8. Disable **Sources → Overrides → Enable Local Overrides**. Repeat with
real authorised staging apps.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-12-02 14:05:39 +07:00
Danny WhiteandJoshen Lim 0265ff935e feat(studio): configure direct database access in OAuth app settings (#54006)
> [!WARNING]
> Partner eligibility requires
[CTRL-2282](https://linear.app/supabase/issue/CTRL-2282) in the target
environment; production deployment is pending.

## Problem

Trusted Partners need to configure direct database access for OAuth
apps. [DEPR-733](https://linear.app/supabase/issue/DEPR-733)

## Solution

- Save and reload direct-access scopes independently of Database
management.
- Allow new grants only for eligible organisations and
organisation-bound apps.
- Allow existing direct access to be removed when eligibility changes.

| After |
| --- |
| <img width="1280" height="754" alt="OAuth Apps Organization Settings
Basket Supabase"
src="https://github.com/user-attachments/assets/e9b78fb6-65e4-4299-ad07-a2f9538a36d5"
/> |
| `"is_trusted_partner": false` or missing |
| <img width="1280" height="754" alt="OAuth Apps Organization Settings
Basket Supabase (1)"
src="https://github.com/user-attachments/assets/cf78db2c-952c-47e9-9239-82aab2c8398a"
/> |
| `"is_trusted_partner": true` |

## Review instructions

1. Open the [staging
preview](https://studio-staging-git-dnywh-depr-733-oauth-app-dat-c71d4a-supabase.vercel.app/dashboard),
select a test organisation and open **OAuth Apps**. It should already be
`true, but enable `enableScopedOAuthPublish` in the Studio dev toolbar’s
**Flags** tab if needed.
2. Open Chrome DevTools → **Network**, then click **Publish OAuth app**.
3. In Network, select the **GET** request whose URL ends in
`/platform/organizations/YOUR_ORG_SLUG`, without `/oauth/apps` after it.
Its response contains the organisation’s name and slug.
4. Right-click that request → **Override content**. Choose a local
folder and click **Allow**. Add `"is_trusted_partner": true` to the
top-level JSON object, keeping every other field. Save with
**Cmd/Ctrl+S**.
5. Reload with DevTools open, reopen **Publish OAuth app**, and choose
**An owner, once for the whole organization** under authorisation.
6. Under **Application permissions**, find **Direct database access**.
Try **No access**, **Read only** and **Read and write**. Change
**Database management** separately and check the two values stay
independent.
7. With direct access selected, check **Each member, for themselves** is
unavailable. Set direct access to **No access**, choose member
authorisation, and check the Direct database access dropdown becomes
disabled.
8. Switch back to organisation authorisation, select direct access and
open **Preview consent for users**. Check its label and access level
match the form.
9. Change the overridden field to `false`, save and reload. Reopen the
new-app form and check Direct database access is hidden.
10. Disable **Sources → Overrides → Enable Local Overrides**. In a
genuinely eligible staging organisation, create a disposable app with
direct access, save and reopen it. Change its access level, save and
reopen again, then remove direct access. Check Database management
remains unchanged.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-12-02 16:50:36 +11:00
Danny White 30a1b38da0 feat(studio): rename temporary access to database token access (#54282)
## Problem

The database access preview still uses “Temporary access” across its
settings and member rules.

## Solution

Use “Database token access” for the feature and “Member access” for
member rules. Update the preview, settings, dialogs, feedback, member
status messages and docs together. Move the guide to
`/guides/platform/token-access`, permanently redirect the old URL, and
preserve existing section anchors.

## Review instructions

1. Open [the Studio
preview](https://studio-staging-git-dnywh-database-token-access-naming-supabase.vercel.app),
then Feature previews and find **Database token access**. Enable the
preview for a supported project, then open [Database
Settings](https://studio-staging-git-dnywh-database-token-access-naming-supabase.vercel.app/project/_/database/settings).
2. Check the **Database token access** heading, **Allow token access**
switch and **Member access** table. Open **Add rule** and an existing
rule to check the sheet titles. Open a rule’s delete confirmation and
cancel it.
3. With an assigned role, check the access status above the member
table. As a member without management permission, check the access
notice uses the same feature name.
4. Open the [database token access guide in the docs
preview](https://docs-git-dnywh-database-token-access-naming-supabase.vercel.app/docs/guides/platform/token-access).
Check the guide and navigation use the new name, the dashboard
instructions match Studio, and the existing section links from the
member guide still work. Open `/docs/guides/platform/temporary-access`
and its `.md` variant to check they permanently redirect to the new
URLs.

| Before | After |
| --- | --- |
| <img width="726" height="367" alt="CleanShot 2026-11-30 at 16 06 00"
src="https://github.com/user-attachments/assets/be351f0c-d578-4289-8785-5c4e69a254a7"
/> | <img width="729" height="374" alt="CleanShot 2026-11-30 at 16 05
38"
src="https://github.com/user-attachments/assets/f02b470d-ef1a-4b6c-bdbb-20fe10b847c6"
/> |
2026-12-02 00:03:43 +00:00
K-Dog (Kevin) dc4f247e79 Revert "chore: update prod api types (#54394)" (#54404)
This reverts commit 37d4f444b4.

OpenFGA model needs updating first before updating the API types
2026-12-01 21:46:40 +08:00
Alaister YoungandAlaister Young b6c391a058 [FE-5114] (part 1) – refactor(studio): add native API helpers & routes (#54028)
## Problem

Studio's `routes/api/**` server routes still run legacy Next Pages
Router handlers through the `toWebHandler` shim in `compat/next/api.ts`.
Part 1 of 7 for
[FE-5114](https://linear.app/supabase/issue/FE-5114/rewrite-api-routes-as-native-tanstack-start-handlers-and-remove-the)
adds native TanStack Start (`Request` → `Response`) helpers and migrates
the top-level utility routes so we can remove the adapter at the end of
the stack.

## Solution

**Added:**

- `createApiHandlers` in `lib/api/apiWrapper.ts`: wraps native TanStack
Start route handlers with optional platform JWT auth, JSON `400` (`{
error: { message: 'Invalid JSON' } }`) on `InvalidJsonError`, Sentry
capture + generic `500` on unexpected throws, and an `ANY` handler that
returns `405` with an `Allow` header derived from the registered
methods. Exports `ApiHandler` / `ApiHandlerContext` (`params` is
`Record<string, string>`)
- `authenticateRequest` in `lib/api/apiAuthenticate.ts` (Web `Request`
counterpart of `apiAuthenticate`, same error messages)
- `InvalidJsonError` and `parseJsonBody` in `lib/api/apiHelpers.ts`
- `callRoute(route, request, params)` test helper in
`tests/lib/server-route.ts`
- Unit tests for `createApiHandlers` (exercising real
`authenticateRequest` through MSW in
`lib/api/createApiHandlers.test.ts`), `authenticateRequest`,
`parseJsonBody`, `/api/generate-attachment-url`, and
`/api/integrations/stripe-sync`

**Changed:**

- Updated `getRouteHandler` in `tests/lib/server-route.ts` to mirror
TanStack Start's `HEAD` → `GET` → `ANY` dispatch order
- Migrated 11 top-level API routes (`check-cname`,
`cli-release-version`, `content/graphql`, `edge-functions/test`,
`enabled-features-overrides`, `generate-attachment-url`,
`get-deployment-commit`, `get-ip-address`, `get-s3-keys`,
`get-utc-time`, `integrations/stripe-sync`) to native handlers
- Added `withAuth: true` to `check-cname`, `content/graphql`, and
`integrations/stripe-sync`, and updated `check-cname-mutation.ts` and
`data/graphql/execute.ts` to attach `constructHeaders()`
- Reused `withAuth` `claims` in `generate-attachment-url` to avoid a
duplicate GoTrue lookup in platform mode
- Converted `tests/routes/api/get-deployment-commit.test.ts` to
`callRoute`

**Removed:**

- Removed 2 unused routes (`routes/api/connect/index.ts` and
`routes/api/parse-query.ts`), dropped `/parse-query` from
`lib/hosted-api-allowlist.ts`, removed Nitro's `traceDeps:
['libpg-query*']` in `vite.config.ts` (no server runtime route imports
`libpg-query` anymore), and regenerated `routeTree.gen.ts`

**Behavior changes vs master:**

- Methods a route doesn't register now get a JSON `405` with an `Allow`
header (previously they fell through to the SSR app). `HEAD` requests
that TanStack Start dispatches to a `GET` handler also get `405`,
matching master's method switches
- `InvalidJsonError` returns JSON `{ error: { message: 'Invalid JSON' }
}` (`400`) instead of plain text
- `check-cname`, `content/graphql`, and `integrations/stripe-sync` now
verify the platform JWT via `withAuth: true`
- Unexpected throws return a generic `500` with `{ error: { message:
'Internal Server Error' } }`
- Unused `/api/connect` and `/api/parse-query` routes have been removed

## Review instructions

1. Run `pnpm --filter studio exec vitest run
lib/api/apiAuthenticate.test.ts lib/api/apiHelpers.test.ts
lib/api/apiWrappers.test.ts lib/api/createApiHandlers.test.ts
tests/routes/api/ scripts/__tests__/server-source-maps.test.ts`.
2. Smoke-test `/api/get-deployment-commit`, `/api/check-cname`,
`/api/content/graphql`, `/api/generate-attachment-url`, and
`/api/edge-functions/test` in Studio and confirm unsupported HTTP
methods return `405` with an `Allow` header.

## Checklist

- [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: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 20:53:57 +08:00
K-Dog (Kevin) 37d4f444b4 chore: update prod api types (#54394)
Updated API types and addressed any type issues. Had to update
shared-types alongside.
2026-12-01 19:42:54 +08:00
Alaister YoungandAlaister Young 0a4cec0464 [FE-5108] (part 1) refactor(studio): migrate core UI & prefetchers off next/link (#54304)
Part 1 of a 6-PR stack migrating all `next/link` imports in
`apps/studio` onto TanStack Router's `Link` (or plain `<a>` for known
external URLs) and removing `compat/next/link.tsx`.

| Part | PR | Scope |
| --- | --- | --- |
| **1** | **#54304 ← this PR** |
**`data/prefetchers/PrefetchableLink.tsx` and `components/ui/**`** |
| 2 | #54305 | `components/layouts/**` and top-level shell components |
| 3 | #54306 | Database, TableGridEditor, Storage, SQLEditor,
BranchManagement, Branching, Functions, Realtime |
| 4 | #54307 | Integrations, Settings, Observability, LogDrains, Issues,
Linter, Reports, QueryPerformance, QuerySources, ConfigDrift,
DiskManagement, Compute |
| 5 | #54308 | Remaining `components/interfaces/**` (Org, Billing, Auth,
Support, Home, SignIn, ConnectSheet, etc.) |
| 6 | #54309 | Remove `compat/next/link.tsx` shim, Vite alias, and
update basePath tests/docs |

Migrates `data/prefetchers/PrefetchableLink.tsx` and all shared
`components/ui/**` components off `next/link`.

**Added:**

- `apps/studio/components/ui/DynamicLink.tsx` (with unit tests) — shared
`forwardRef` link wrapper for dynamic URL strings that runs
`splitInternalUrl` and renders a plain `<a>` for external URLs (or
same-origin URLs outside the app's `basePath`) vs TanStack `<Link>` for
internal paths

**Changed:**

- Replaced `next/link` in
`apps/studio/data/prefetchers/PrefetchableLink.tsx` and all 30 importing
components under `apps/studio/components/ui/**` (`InlineLink`,
`CardButton`, `CommandItemLink`, `ObservabilityLink`, `ProductMenuItem`,
`ResourceItem`, `UpgradePlanButton`, `ToggleSpendCapButton`, banners, AI
assistant panel links, etc.)
- Used typed `<Link to="..." params={...} search={...} hash="..." />`
for known internal routes, `<DynamicLink href={...} />` for
dynamic/untyped URL strings (whether internal with query/hash or
external), and plain `<a>` for known external links
- Updated `apps/studio/routes/index.tsx` `validateSearch` return type to
`{ next?: string }` so `<Link to="/">` compiles without requiring
`search={{ next: undefined }}`
- Updated
`hooks/misc/__tests__/useTableEditorFiltersSort.navigation.test.tsx`,
`PolicyTableRow.utils.test.ts`, `SupportAssistantSuccessCard.test.tsx`,
and `useOrganizationRestrictions.test.tsx` to render inside a TanStack
Router context (`customRender` / `RouterContextProvider`)

Addresses
[FE-5108](https://linear.app/supabase/issue/FE-5108/replace-the-nextlink-shim-with-tanstack-link)

## To test

- [ ] Click internal and external `InlineLink`, `CardButton`,
`ProductMenuItem`, and `PrefetchableLink` targets and verify client-side
navigation vs external anchors
- [ ] Verify banner links (upgrade, resource exhaustion, queue
operations) preserve query params and hashes
- [ ] Confirm Studio typecheck, lint, and unit tests pass

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 16:23:48 +08:00
Jordi Enric c2edb29076 fix(studio): explain Supavisor session pool limits DEBUG-43 (#53930)
## Problem

When Supavisor rejects a session because its connection pool is full,
Studio shows the error without explaining how to recover.

## Fix

Show a troubleshooting step for the session-mode limit that explains how
pool size limits concurrent clients and links to the configuration
guide.

## Screenshot

The Table Editor’s troubleshooting step, rendered locally with a sample
session-pool error.

<img width="660" alt="Expanded Supavisor session pool limit guidance in
the Table Editor"
src="https://github.com/user-attachments/assets/6072eec4-e243-4d53-a40f-30fb14d21d05"
/>

## How to test

- Display a classified MaxClientsInSessionMode error in Studio and
expand its troubleshooting step. The link should open the pool size
section of the database connection management guide.
- Display a generic transaction-mode connection limit error. It should
keep its usual fallback.
- The pattern, classification and ErrorMatcher suites exercise these
paths (144 tests passed locally).

Fixes [DEBUG-43](https://linear.app/supabase/issue/DEBUG-43).
2026-11-30 16:49:05 +01:00
K-Dog (Kevin) 27c4433a3e feat: revised project add-ons page (#54186)
The current add-ons page only lists a subset of available add-ons, which
often causes confusion with things like Advanced MFA Auth (customers
cant find where to configure it).

The revised add-on page covers all potentially configured project
add-ons including replicas and advanced disk. This should help the
customer locate configured add-ons and at the same time discover
potentially interesting add-ons. This can be enhanced further in the
future with "smart" suggestions based on usage.
2026-11-30 21:54:44 +08:00
Tyler HilleryandClaude d7ad2cdb32 fix(studio): order object versions by archived_at (#54104)
## Problem

Object versions are sorted by `created_at`, but a version's `created_at`
doesn't always reflect when it was written. When a bucket is suspended,
an upload replaces the null version in place and keeps that row's
original `created_at`, so the current version can show up below older
ones in the versions panel.

## Solution

Sort by `archived_at`. The current version has no `archived_at`, so it
comes first, followed by the most recently archived.

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-30 12:55:14 +01:00
Joshen Lim 15e95ab013 Joshenlim/fe 5242 jit db access show assigned role (#54214)
## Context

Building on top of https://github.com/supabase/supabase/pull/54192,
there was a missing piece to the JIT DB access UI which was showing the
assigned access to the user if any (On staging it just shows an error,
on the previous PR we show a "Contact your project admin" CTA).

So this PR addresses that - there's a couple of cases to consider and
I'd love for design to feedback / adjust as well as I'm not convinced
this is the best way to do things. Am deliberately leaving out the
"copyable connection strings" part for now as Danny's investigating into
that one

### If you're a non-owner

If not assigned a role:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/111d7c4f-0083-4bd5-88d5-ec45974ccf4d"
/>

If assigned a single role:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/1b4b1f3c-9a20-4010-bff8-7bf68a455e26"
/>

If assigned multiple roles:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/42cc66f6-4604-42eb-ab30-f58b1396ca6b"
/>
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/0914e1a3-9c7d-463e-851d-65f6b9793bb7"
/>

If (all) access expired:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/bda0fc65-e22a-49d9-b444-fc5d58a4745a"
/>

### If you're an owner

If not assigned a role: Status quo
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/435abe70-ae88-49bb-86b9-7a03963b5b66"
/>

If yourself is assigned a role:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/9fafc74a-1a33-489e-a7da-70f57356a034"
/>

If yourself is assigned multiple roles:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/f4af901b-a24e-4272-b573-9ccb474bb7e2"
/>

If (all) access expired: Same as not assigned a role, just refer back to
the table
2026-11-30 12:57:24 +07:00
K-Dog (Kevin) 4e589266af chore(billing): revised card errors (#54179)
- Improved error messaging around card errors and toast position to be
closer to the actual action (customers often miss it in the top right)
- For card errors when setting up payment methods with a direct error
via the Stripe API, map to an appropriate actionable error message
2026-11-28 12:57:32 +08:00
Julian Domke d85e9b8616 feat(billing): use new upcoming invoice data (#53342)
Makes use of the new data returned from the upcoming invoice endpoint
and wraps it in an accordion-based layout.

The current implementation is fairly bare-bones, so discussed with
@kevcodez that we roll out this version first (which should already be
an improvement), then talk to a designer on the team to get it polished.

Ran `pnpm api:codegen:prod` from the root of the repo.

The $10.01 in Compute Credits are an upstream data issue on Orb 😢 

## Testing

If you'd like to test this in the browser, these are the steps:

1. checkout commit, launch local stack, create org + project; upgrade to
paid
2. reach out to me so I can set up some usage and credits for your
project/org
3. click around the upcoming invoice


https://github.com/user-attachments/assets/6a814560-5d05-479a-a3f8-d658532b91c1

<img width="1180" height="235" alt="Screenshot 2026-11-13 at 10 03 01"
src="https://github.com/user-attachments/assets/682083b7-77ea-4da8-a599-36f5063e922b"
/>
<img width="910" height="235" alt="Screenshot 2026-11-13 at 10 02 59"
src="https://github.com/user-attachments/assets/59903f2a-2af4-4e18-8d97-35baee7401e0"
/>

<img width="815" height="140" alt="Screenshot 2026-11-13 at 12 03 17"
src="https://github.com/user-attachments/assets/4370d10a-dc5a-4010-b03e-dcf0b23140d1"
/>
<img width="507" height="143" alt="Screenshot 2026-11-13 at 12 03 21"
src="https://github.com/user-attachments/assets/3243855e-b02a-4e93-8139-5a7dfaad3230"
/>
2026-11-27 13:24:54 +01:00
Alaister YoungandAlaister Young d98f706b7c [FE-5109] (part 1) refactor(studio): migrate core hooks, lib, and prefetchers off next/router (#54053)
Part 1 of a 6-PR stack migrating all `next/router` and
`next/compat/router` imports in `apps/studio` onto TanStack Router hooks
and removing the router shims.

| Part | PR | Scope |
| --- | --- | --- |
| **1** | **#54053 ← this PR** | **Core navigation helpers, `hooks/**`,
`lib/**`, `data/prefetchers/**`** |
| 2 | #54054 | `components/ui/**` |
| 3 | #54055 | `components/layouts/**` and `state/tabs.tsx` |
| 4 | #54056 | Database, Branching, Compute, Edge Functions, Explorer,
SQL Editor, Storage, Table Editor |
| 5 | #54057 | Remaining `components/interfaces/**` and
`QueryInsightsTable` router events |
| 6 | #54058 | Remove `next/router` & `next/compat/router` shims,
`_router-events.ts`, Vite aliases, and test mocks |

Introduces the shared TanStack navigation helpers needed across the
stack and migrates `hooks/**`, `lib/**`, and `data/prefetchers/**` off
`next/router`.

**Added:**

- `navigateToUrl` in `apps/studio/lib/navigation.ts` (plus unit tests in
`lib/navigation.test.ts`): shared helper for navigating to internal
string URLs via TanStack's `useNavigate` (splitting pathname, search
params, and hash via `splitInternalUrl`, and handling
external/protocol-relative URLs)
- `useRoutePattern` in `apps/studio/hooks/misc/useRoutePattern.ts` (plus
`useRoutePattern.test.tsx`): returns the active matched TanStack route
template (e.g. `/project/$ref/editor/$id`) as the replacement for Next's
`router.pathname`

**Changed:**

- Migrated `hooks/misc/*` (`useHydratedQuery`,
`useStudioCommandMenuTelemetry`, `useTableEditorFiltersSort`,
`withAuth`) and `hooks/use-check-latest-deploy.tsx` to TanStack's
`useLocation`, `useNavigate`, `useRoutePattern`, and `useParams` from
`common`
- Migrated `lib/profile.tsx` and `lib/telemetry/track.ts` off
`next/router`
- Migrated `data/prefetchers/project.$ref.tsx`,
`project.$ref.editor.tsx`, and `project.$ref.editor.$id.tsx` to
`useRouter().preloadRoute`
- Wrapped `ReactQueryTestConfig` in `apps/studio/tests/helpers.tsx` with
`RouterContextProvider` and updated hook/navigation tests
(`useTableEditorFiltersSort*.test.*`,
`useFilterLifeCycle.navigation.test.tsx`,
`useTableFilter.navigation.test.tsx`, `useInboundBranding.test.ts`,
`state/tabs.test.ts`)

**Simplified:**

- `navigateToUrl` passes `replace` straight through and documents that
`url` must be an app-relative path or an external URL.
`StudioFrameworkProvider`'s `push` now reuses it.
- `useRoutePattern` reads matches and location in a single
`useRouterState` subscription
- `useTrack` and `useStudioCommandMenuTelemetry` take the pathname from
`useFramework()`, the same source as pageviews, so custom events and
pageviews always send the same pattern (e.g. `/project/[ref]/sql/[id]`).
New tests pin the strings sent, and `toRoutePattern` now has its own
unit tests.
- Removed `useCurrentPath` (a one-line wrapper with one consumer):
`OrganizationSettingsLayout` calls `useLocation` directly
- Dropped the no-op `.catch(() => {})` on `preloadRoute` in the
prefetchers (`preloadRoute` never rejects)
- `useTableEditorFiltersSort` builds the next search with a spread
instead of a delete loop
- Added `createTestRouter()` to `tests/lib/custom-render.tsx`, and
`customRender`/`customRenderHook` now return the `router`. The rest of
the stack uses these instead of hand-copied `createRouter` setups.

Addresses
[FE-5109](https://linear.app/supabase/issue/FE-5109/replace-the-nextrouter-shims-with-tanstack-router-hooks)

## To test

- [ ] Auth redirect flow (`withAuth`) still preserves `returnTo` query
parameters when redirecting unauthenticated users to `/sign-in`
- [ ] Table Editor sort and filter URL sync
(`useTableEditorFiltersSort`) persists and clears `?sort=` / `?filter=`
across table switches
- [ ] Hovering project and table editor links still triggers route/data
prefetching without console errors
- [ ] Page view and command menu telemetry still records route patterns
and paths accurately

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-27 09:37:49 +00:00
Francesco Sansalvadore cbcdf4c84c fix(studio): storage lifecycle policy execution (#54138)
## Problem

Non-current versions in storage weren't showing the correct expiration
value based on the lifecycle policies settings.

## Solution

Fix client logic and improve communication around expiration.

Adding "Archived at" info make the version history crowded, so some
information has been moved into the dropdown menu of each noncurrent
version.

<img width="445" height="314" alt="Screenshot 2026-11-26 at 16 58 23"
src="https://github.com/user-attachments/assets/efb345f7-9a1c-4a53-b5e2-8b05505f9856"
/>

Note: when the "Newest noncurrent versions to keep" threshold is met,
older versions that exceed such thresholds will expire no earlier than
in 1d.

## Review instructions

- Enable object versioning and set lifecycle policies on a File Storage
bucket
- add new versions to reach and exceed policy threasholds
- check that expiration rules apply as intended
2026-11-27 10:25:51 +01:00
Pamela Chia 0755ba6556 feat(studio): use the onboarding survey in the AWS Marketplace org form (#53938) 2026-11-26 23:27:19 +08:00
K-Dog (Kevin) 0246fb34b5 fix: clear free project limit cache on project operations (#54108)
When pausing/creating/restoring/cloning a project, we are not clearing
the react-query cache for the free project limit check and therefore
still displaying potentially wrong states to the user.

PR addresses this by clearing the free project limit react query cache
on relevant project operations.
2026-11-26 16:16:45 +08:00
Alaister YoungandAlaister Young 8f75187422 fix(studio): stop dev No queryFn error from grantedQueryOptions (#54004)
Fixes TanStack Query spamming `No queryFn was passed as an option` in
dev whenever a grant-gated query renders without a grant or required
variable (such as `branchesQueryOptions` when `projectRef` is
`undefined`).

**Changed:**

- Replaced `queryFn: undefined` in `grantedQueryOptions` with a stable
`fallbackQueryFn` while keeping `enabled: false`. This satisfies
`useBaseQuery`'s dev-mode check and still delegates to a subscribed
granted observer on invalidation (avoiding the `skipToken` shared-cache
regression from #53088).
- Updated `granted-query-options.test.ts` and `api-keys-query.test.tsx`
to verify no `console.error` is logged when rendering without a grant or
`projectRef` and that invalidation still refetches via the granted
observer.
- Updated the `studio-queries` skill note to match.

## To test

- Run `pnpm dev:studio` and open a non-branch project's home page.
Confirm the browser console and dev terminal no longer spam
`[["projects",null,"branches"]]: No queryFn was passed as an option`.
- Open Project Settings -> API Keys, create or delete a key, and confirm
the list still refreshes cleanly.
- Run `pnpm --filter studio test data/granted-query-options.test.ts
data/api-keys/api-keys-query.test.tsx`.

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-26 01:01:33 +08:00
Drew McLellan 4fa8afe918 feat(studio): support grouped OR filters in unified logs (#53943) 2026-11-25 10:42:36 +00:00
Jordi Enric 15fcb7dc49 fix(studio): refresh observability charts for the selected range FE-5122 (#53931)
## Problem

A custom date range in a Storage report URL could show one window in the
header and another in the charts. Refresh also left Database Size and
several Auth charts showing cached results.

## Fix

Use the selected window for all Storage report requests, run the
Database Size query on refresh, and refresh Auth Usage, Errors and
Latency alongside the shared API charts.

## How to test

- Open Storage with a custom start and end time in the URL. Inspect the
chart requests on load and after Refresh. Both sets should use those
exact timestamps.
- Refresh the Database report and check that the large objects query
runs again.
- Open Auth with a fixed range and press Shift+R. The Usage, Errors,
Latency and API charts should request fresh data for the same range.

Fixes [FE-5122](https://linear.app/supabase/issue/FE-5122).
2026-11-24 15:31:11 +01:00
Alaister YoungandAlaister Young fcbdda8107 chore: migrate formatter from Prettier to oxfmt (#53835)
Migrate code formatting across the monorepo from Prettier to `oxfmt`
(`0.79.0`, pinned) for much faster formatting checks locally and in CI
while keeping code churn minimal (78 files total, 0.7% of the repo).

Studio's `@ianvs/prettier-plugin-sort-imports` ordering
(`<BUILTIN_MODULES>`, `<THIRD_PARTY_MODULES>`, blank line, then `@/` and
relative imports) is preserved via `oxfmt`'s native `sortImports`
override for `apps/studio/**/*.{js,jsx,ts,tsx}`.

### Performance (before vs after, uncached)

| Benchmark | Prettier (`3.8.x`) | oxfmt (`0.79.0`) | Speedup |
| --- | ---: | ---: | ---: |
| CI formatting step (`blacksmith-4vcpu-ubuntu-2404`, full repo) | `73s`
| **`7s`** | **~10×** |
| Local `apps/studio` JS/TS (`5,157` files) | `17.74s` | **`0.36s`** |
**~49×** |
| Local full monorepo (`11,131` files) | — | **`2.39s`** | — |

**Added:**

- `.oxfmtrc.jsonc` at repo root with Prettier-matching options,
`sortPackageJson: false`, the Studio `sortImports` override, and ignore
patterns migrated from `.prettierignore`
- `oxfmt` (`0.79.0` exact pin) in `pnpm-workspace.yaml` catalog and
workspace `devDependencies` / `dependencies`
- Shared `.agents/scripts/format_and_lint.sh` hook script and
`.agents/hooks.json` (used by both Claude Code and Antigravity)

**Changed:**

- Replaced `test:prettier` with `format:check` and switched `format` in
root `package.json` to `oxfmt`
- Updated `packages/api-types` (`codegen`,
`verify-production-types.mjs`), `apps/design-system` (`build:registry`),
`apps/docs` (`CodeSample.ts`, `generate-sitemap.ts`, `next.config.mjs`,
`spec/Makefile`), `apps/www` (`generate-sitemap.mjs`), and
`packages/build-icons` (`generateIconFiles.mjs`) from Prettier to
`oxfmt`
- Updated `.github/workflows/prettier.yml` (keeping the `format` job ID
intact), `.github/workflows/autofix_linters.yml`,
`.claude/settings.json`, `AGENTS.md`, `CONTRIBUTING.md`, and
`.github/copilot-instructions.md`
- Applied one-time `oxfmt` formatting pass in a separate commit (78
files: 30 `i18n/README.*.md` trailing spaces, 19 Studio files, 17 other
TS/TSX/generated types, 8 MD/MDX, 3 `package.json`, 2 example CSS files)

**Removed:**

- `prettier`, `@ianvs/prettier-plugin-sort-imports`, and
`prettier-plugin-sql-cst` from `devDependencies` (note: `.sql` files
were not part of the CI formatting glob; `eslint-config-prettier` is
kept for ESLint)
- `prettier.config.mjs`, `.prettierignore`, and
`.claude/scripts/format_and_lint.sh`

## To test

- Run `pnpm run format:check` and confirm it passes cleanly across all
matched files
- Run `pnpm --filter api-types test`, `pnpm --filter docs exec vitest
run features/directives/CodeSample.test.ts`, and `pnpm --filter www exec
vitest run generate-sitemap.test.ts`
- Edit an `apps/studio` file with out-of-order imports and run `pnpm run
format` to confirm builtin/third-party vs `@/`/relative grouping matches
prior behavior
- Check that the `Check Code Formatting` CI workflow passes on this PR

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-24 12:51:31 +08:00
Joshen Lim 4a73166675 Add support for downloading edge functions when file size exceeds max cap (#53709)
## Context

Just creating a separate PR cause I messed up the [previous
one](https://github.com/supabase/supabase/pull/53453) with a bad merge 🫠
Also changed the implementation to no longer use `@deno/eszip`.

For edge functions, functions which exceed 5MB cannot be fetched and
displayed in the dashboard editor (API will return a 507). The CTA we
give to users is to download the function via the CLI, but this PR
explores allowing users to download their edge functions via the browser
still, by calling `/v1/functions/slug/body` without the
`multi-part/data` header. This returns the function in a raw eszip
stream which we're then parsing using a custom reader

We'll do this via the "Download as ZIP" CTA here - but this way of
downloading only kicks in if the GET Edge Function body endpoint returns
a 507. Otherwise it'll just be status quo where we bundle the files that
were already fetched to render in the browser into a ZIP file.
<img width="343" height="186" alt="image"
src="https://github.com/user-attachments/assets/4ffc9fee-7e6d-46a6-bdbe-294610abc802"
/>

Also updated the warning for 507s:
- To use a normal admonition instead of `AlertError` since its
technically not an issue
- To avoid rendering the API error message in this case specifically as
the API message contains "Use multipart instead" which isn't relevant to
the dashboard from a user's POV
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/8242a875-f142-419d-81f0-0dbc30807f87"
/>

## To test

- [ ] Upload an edge function of size larger than 5MB to a staging
project via the CLI
- [ ] Verify that there's an Admonition for the large function instead
of an error
- [ ] Verify that you can still download the edge function via the
Download button (Which triggers a POST /body request without multipart)
2026-11-23 10:59:57 +07:00
kemal.earth 53f2bb416d feat(studio): saved views in sidebar (#53630)
## Problem

Unified Logs had saved views behind a dropdown in the toolbar. The
dropdown couldn't show more than a name per row, had no room for
grouping, and gave new projects nothing to start from — an empty list
until you built and saved a filter combination yourself.

## Solution

Moved saved views into the filter sidebar as a second level, following
the Explorer notebooks/chats pattern: a Saved views button in the
sidebar header swaps the filters out for a Views panel, with a
breadcrumb back to Logs.

Key choices:

- **`FilterSideBar` stays generic.** It takes `section`, `headerAction`
and `onReset` slots; all saved-views specifics live in `LogsViewsPanel`.
- **Presets are virtual, not seeded.** Three built-in views (Errors,
Failed requests, Database health) render from a constant with `preset:`
ids. No per-project write, so they work for read-only members and can't
be deleted into oblivion. They can be duplicated into a real saved view,
but not renamed, edited or deleted.
- **One dialog for naming.** `ViewNameDialog` backs create, rename and
duplicate.
- **Clicking a modified view opens the update prompt** instead of
re-applying it, which previously discarded unsaved filter edits with no
warning.

Also fixed two pre-existing alignment issues in the sidebar: filter
options sat 4px left of their section heading, and the User filter — a
hand-copied clone of the filter row markup — had drifted from the shared
one.

## Review instructions

1. Enable the Unified Logs feature preview and the `logsSavedViews`
flag, then open **Logs**.
2. Click the layers button in the sidebar header. The filters swap for
the Views panel, with **Preset views** above **Saved views**.
3. Click **Errors**. The filter applies and the row highlights; the
layers icon turns green.
4. Change a filter. The row reads **Modified** and the update prompt
appears. Go back to Logs and return — the prompt is still available.
5. Open the ⋮ menu on a preset: only **Duplicate** is offered. Duplicate
it and confirm it lands under Saved views with rename/delete available.
6. Click **+** in the Views header to save the current filters, then
rename and delete it.
7. Hit the reset button in the header and confirm the active view clears
along with the
   filters.
2026-11-20 15:28:59 +00:00
Danny WhiteandJoshen Lim 2372aa0fc2 feat(studio): show Warehouse query latency (#53570)
## Problem

The Warehouse report shows query activity and outcomes, but not how long
queries spend waiting or running.

## Solution

Add query-duration percentiles, worker-acquisition waits and
successful-query duration. Durations are shown in milliseconds, with
missing measurements kept distinct from zero. Latency loads separately
so a failed request does not hide query activity.

| After |
| --- |
| <img width="1678" height="1796" alt="CleanShot 2026-11-18 at 12 28
53@2x"
src="https://github.com/user-attachments/assets/48c6545e-8f2d-40c4-aa3c-977dd2ae6479"
/> |
| _New latency section._ |

## Review instructions

1. Open the [Studio staging
preview](https://studio-staging-git-dnywh-warehouse-report-latency-supabase.vercel.app)
with a staging project that has Warehouse access
([example](https://studio-staging-git-dnywh-warehouse-report-latency-supabase.vercel.app/dashboard/project/yirnfrgkxmnqgexikhfc/observability/warehouse?its=2026-11-18T00%3A23%3A52.901Z&ite=2026-11-18T01%3A23%3A52.901Z&isHelper=true&helperText=Last+60+minutes)),
then go to **Observability > Warehouse**.
2. Check **Query duration**, **Time waiting for a worker** and
**Successful query duration** below the query charts. Hover the lines to
compare timing measurements.
3. Change the date range and refresh. Both query activity and latency
should update.
4. Check the selected period without measurements. Empty or unavailable
data must remain distinct from measured zeroes.

Shared ChartLine accessibility changes are separate in #53706.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-11-20 15:46:02 +11:00
Gildas Garcia 4442d91d77 feat(studio): Wire org and users authorized apps list to backend (#53674)
## Description

Part of the work for OAuth apps with the scoped permissions. This PR
wires the org and users authorized apps lists to backend.
2026-11-19 21:40:12 +01:00
Gildas Garcia 10488ed799 feat(studio): Wire the OAuth apps consent screen to the backend (#53511)
## Description

Part of the work for OAuth apps with the scoped permissions. This PR
wires consent screen to the backend.

## Review instructions

### Setup
Copy the `examples/oauth-app-authorization-flow/.env.example` to
`examples/oauth-app-authorization-flow/.env`

> [!IMPORTANT]  
> In next steps, make sure to copy the apps ids/secrets in the
`examples/oauth-app-authorization-flow/.env` with a way to differentiate
them:
> ```
> # org bound all projects
> SUPABASE_CLIENT_ID=xxx
> SUPABASE_CLIENT_SECRET=xxx
> ```

As an organization admin, go to the _Organization settings/OAuth Apps_
and create the following _Publishable apps_:

- `test_org_bound`: 
  - _Use the permissions of the person who connects_ unchecked
  - _Ask for specific projects_ unchecked
  - Select only _Database Read_ for the permissions
 
- `test_org_bound_projects`: 
  - _Use the permissions of the person who connects_ unchecked
  - _Ask for specific projects_ checked
  - Select only _Database Read_ for the permissions

- `test_member_bound`: 
  - _Use the permissions of the person who connects_ checked
  - _Ask for specific projects_ unchecked
  - Select only _Database Read/Write_ for the permissions
 
- `test_member_bound_projects`: 
  - _Use the permissions of the person who connects_ checked
  - _Ask for specific projects_ checked
  - Select only _Database Read/Write_ for the permissions

Make sure you have 3 projects in the org. Add a team member that have
Administration rights on the first project, read-only access to the 2nd
and no access to the third.

Install the `examples/oauth-app-authorization-flow` dependencies and
start the app.
- `test_org_bound`: 
  - connected on studio as the org admin
    - click the `oauth-app-authorization-flow` button
- check that you don't have to select a project on the consent screen
- check that the permissions requested are correct and you can approve
the app
- update the published app to include the _Database Write_ permissions
- return to the `oauth-app-authorization-flow` index and click its
button again
- check that the consent screen shows the permissions difference and
approve it again
- connected as a simple team member, check that you have a message
indicating you can't approve this app
  
- `test_org_bound_projects`: 
  - connected on studio as the org admin
    - click the `oauth-app-authorization-flow` button
    - check that you have to select projects on the consent screen
- check that the permissions requested are correct and you can approve
the app
- update the published app to include the _Database Write_ permissions
- return to the `oauth-app-authorization-flow` index and click its
button again
- check that the consent screen shows the permissions difference and
approve it again
- connected as a simple team member, check that you have a message
indicating you can't approve this app

- `test_member_bound`: 
  - connected on studio as a member 
    - click the `oauth-app-authorization-flow` button
- check that you don't have to select a project on the consent screen
- check that the permissions requested are correct and you can approve
the app
    - update the published app to add another permission
- return to the `oauth-app-authorization-flow` index and click its
button again
- check that the consent screen shows the permissions difference and
approve it again
   
- `test_member_bound_projects`: 
  - connected on studio as the org admin
    - click the `oauth-app-authorization-flow` button
- check that you have to select projects on the consent screen (you
should see only the two you have access to) and select them all one by
one
    - check that the permissions requested are correct
- approve the app and check that you have an error related to the
project with read-only access
    - unselect it and approve the app
- update the published app to include the _Database Write_ permissions
- return to the `oauth-app-authorization-flow` index and click its
button again
- check that the consent screen shows the permissions difference and
approve it again
2026-11-19 17:47:03 +01:00
Danny WhiteandJoshen Lim 48c90094d9 feat(studio): show Warehouse query activity in Observability (#53495)
## Problem

Warehouse query activity is not available in Observability.

## Solution

Add a Warehouse report showing query rate over the last hour, with
loading, setup, no-data and request-error states. The report uses live
project metrics and appears in navigation for projects with Warehouse
access.

| After |
| --- |
| <img width="2548" height="1416" alt="CleanShot 2026-11-17 at 16 55
33@2x"
src="https://github.com/user-attachments/assets/4d6796e0-72f1-45d5-b6b7-2cd4a3577496"
/> |
| <img width="2552" height="1390" alt="CleanShot 2026-11-17 at 16 56
18@2x"
src="https://github.com/user-attachments/assets/d96efdfd-4ca9-42fe-ac30-9cb4667c95d7"
/> |
| <img width="2544" height="1388" alt="CleanShot 2026-11-17 at 16 32
11@2x"
src="https://github.com/user-attachments/assets/bc80af8d-0468-4229-98d0-ac2681823059"
/> |
| <img width="2560" height="1344" alt="CleanShot 2026-11-17 at 16 59
53@2x"
src="https://github.com/user-attachments/assets/1ed70348-c2fc-4673-85a7-530d9734886c"
/> |


Visitor | What they see
-- | --
Signed-in customer without Warehouse access | No Warehouse entry in
Observability
Customer with Warehouse access, not configured | “Warehouse is not set
up” empty state and setup button
Customer with Warehouse disabled | “Warehouse is disabled” empty state
and setup button
Customer with active Warehouse | Query rate chart, or the relevant
loading/empty/error state



## Review instructions

1. Open the [Studio staging
preview](https://studio-staging-git-dnywh-warehouse-metrics-client-supabase.vercel.app)
with a staging project that has Warehouse access.
2. Go to **Observability > Warehouse**, or
`/project/<ref>/observability/warehouse`
([example](https://studio-staging-git-dnywh-warehouse-metrics-client-supabase.vercel.app/dashboard/project/yirnfrgkxmnqgexikhfc/observability/warehouse)).
3. Check the query-rate chart after running Warehouse queries. A project
without measurements shows an explicit last-hour empty state.
4. Open the report on a project where Warehouse is not set up and check
the setup link.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-11-19 14:57:39 +11:00
supabase-vercel-tedd[bot] 248dbefbe9 fix(studio): skip notifications and service status queries without a session (#53538)
## Problem

`useNotificationsV2Query` and `useProjectServiceStatusQuery` run
whenever their component is mounted, whether or not a session exists.
When a session ends and the app redirects to `/sign-in`, they can still
fetch (or refetch) `/platform/notifications` and
`/v1/projects/{ref}/health` with no `Authorization` header. The API then
responds 401 `No access token provided`, and the response is classified
as an `UnclassifiedApiError` and reported.

## Solution

Both hooks now gate `enabled` on `useIsLoggedIn()` from `common`.
`usePermissionsQuery` and `useOverdueInvoicesQuery` already follow this
pattern. The caller's `enabled` option still applies on top of it.
Self-hosted builds always count as logged in, so their behavior is
unchanged.

Checks run:
- `pnpm turbo run typecheck --filter='...[origin/master]'`: passes
- `pnpm turbo run lint --filter='[origin/master]'`: passes. The first
run of `studio#lint:type-checks` ran out of heap memory. It passed on a
rerun with `NODE_OPTIONS=--max-old-space-size=8192`.
- `pnpm exec vitest run
components/layouts/AppLayout/AdvisorButton.test.tsx
components/layouts/AppLayout/AdvisorButton.platform.test.tsx
components/ui/AdvisorPanel/AdvisorSignals.integration.test.tsx` (in
`apps/studio`): passes
- Prettier check on the changed files: passes

## Review instructions

1. Sign out of the Studio preview. Open
`/dashboard/sign-in?returnTo=/project/<ref>`, keep the network tab open,
and confirm that no request to `/platform/notifications` or
`/v1/projects/<ref>/health` returns 401.
2. Sign in and open a project's home page. The service status indicator
still loads its status.
3. Open the Advisor/Issues panel from the header. Notifications still
load, and the header button still shows the unread/critical indicator
when it applies.

## Checklist

- [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)


[FE-4989](https://linear.app/supabase/issue/FE-4989/unclassifiedapierror-no-access-token-provided)

Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
2026-11-18 08:51:47 -05:00
Gildas Garcia 7b37f0c774 feat(studio): update oauth apps mocks and UI to the latest API payloads formats (#53363)
## Description

Part of the work for OAuth apps with the scoped permissions. This PR:
- Update the mock data to the new format returned or expected by the
backend
- Remove unnecessary hooks that have their feature merged in another one
(`useOAuthOrgAppDetailsQuery` is now merged in
`useOAuthAppsPreflightValidationQuery`)

> [!NOTE]  
> At this stage, the UI still only use mock data

## Review instructions

If all tests pass, we're good.
2026-11-18 13:38:19 +01:00
Gildas Garcia b58913895c feat(studio): Refactor OAuth app consent screen for project selection (#53361)
## Description

Part of the work for OAuth apps with the scoped permissions. This PR:
- Update `<MultiSelector>` to allow consumers to react to search terms
changes
- Refactor OAuth app consent screen to ensure we can load projects
asynchronously with an infinite list and server side filtering

> [!NOTE]  
> At this stage, the UI still only use mock data

## Review instructions

If all tests pass, we're good.
2026-11-18 13:16:31 +01:00
supabase-vercel-tedd[bot] f0986f5f24 fix(studio): treat 401 API errors as a user fault for Sentry routing (#53411)
## Problem

A 401 from the platform API means the browser sent no valid session
token: the user signed out, or the session expired. Studio then
redirects to sign-in. `classifyResponseError` turns any 4xx into
`UnclassifiedApiError` with `fault: 'studio'`, so every query that fails
while the session is gone goes to Sentry at the Studio-owned sample
rate. The first query to fail is often the read-replicas query. Sentry
fills with errors that Studio can't fix.

## Solution

- `UnclassifiedApiError` now derives its fault from the status: a 401 is
`user`, and every other 4xx stays `studio`.
- `ERROR_ROUTING.UnclassifiedApiError` gets a `user` entry at
`SAMPLE_USER_FAULT`. 401s still send a small trickle to catch
misclassification, and 403/404/429 keep `SAMPLE_OWNED`.
- Because the fault is `user`, `AlertError` shows the user-fault
presentation for a 401 ("try again / refresh"), with no contact-support
prompt.
- Tests: `handleError.test.ts` expects `user` for a 401, and
`error-routing.test.ts` covers the 401 and 403 routing.

## Review instructions

This change has no new UI. To check it:

1. In `apps/studio`, run `vitest run lib/errors data/handleError.test.ts
data/error-classification.test.ts data/fetchers-errors.test.ts
data/query-client-reporting.test.ts components/ui`. All tests pass.
2. In `apps/studio`, run `eslint` on the changed files. It reports
nothing.
3. `tsc --noEmit` in `apps/studio` reports one error, in
`packages/ui-patterns/src/McpUrlBuilder/components/InstructionBlocks.tsx`.
The same error appears without this change: it comes from running `tsc`
without `next typegen` first.


[FE-5086](https://linear.app/supabase/issue/FE-5086/unclassifiedapierror-no-access-token-provided)

Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
2026-11-18 16:48:25 +07:00
Sean Oliver b23e9e8d94 fix(consent): clear tracking state and reload when consent is withdrawn (#53294)
## Problem

Opting out from the Privacy Settings modal (www, docs, kb) clears no
cookies, and GTM keeps running. The banner's Opt out misses `_ga_<id>`,
`_dcid`, and PostHog.

## Solution

- `revokeTrackingConsent()` runs from `denyAll`, and from
`updateServices` unless every service is accepted. It clears `_ga`,
`_ga_*`, `_gcl_*`, `FP*`, `_dcid`, `session_id`, `ph_*_posthog`,
PostHog's localStorage, stale consent copies.
- PostHog resets and opts out, with persistence off. The opt-out
survives sign-out. A saved accept opts back in.
- Every opt-out calls `POST /platform/telemetry/reset` (keepalive,
errors ignored) to clear the API's HttpOnly `session_id`,
`anonymous_id`, and `user_id`. Studio's own call is removed.
- To stop GTM, a saved opt-out reloads the page if tracking was on,
waiting at most 1s for the reset.

## Review instructions

1. `cd packages/common && npx vitest run consent-state.test.ts
posthog-client.test.ts`
2. On prod: accept, open Privacy Settings, turn Marketing off, Confirm.
The page reloads with cookies gone and no `collect` request.

Tested: `common` (237 pass), `AnalyticsSettings` tests, CI unit tests
and typecheck. No browser test (previews lack Usercentrics).

## Checklist

- [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
2026-11-17 16:38:23 -08:00
Gildas Garcia 45f4a115fa feat(studio): Refactor oauth app consent screen (#53357)
## Description

Part of the work for OAuth apps with the scoped permissions. This PR:
- refactors the authorize OAuth app consent screen to make it more
consistant with how we handle load requests
- remove the copy constants in favor of direct JSX like we do everywhere
- ensure the data hooks have optional parameters with runtime check to
be usable even when all needed data isn't loaded yet

> [!NOTE]  
> At this stage, the UI still only use mock data

## Review instructions

If all tests pass, we're good.
2026-11-17 16:58:49 +01:00
Gildas Garcia dde52ce6e8 feat(studio): update oauth publishable apps to include new options (#53355)
## Description

Part of the work for OAuth apps with the scoped permissions.
This PR updates the publishable apps UI to actually submit the new
options

> [!NOTE]  
> The backend may reject the API call if your organization isn't
enrolled in scoped oauth apps. That does not prevent to check the
payload is correct

## Review instructions

- Open _Organizations settings/OAuth Apps_
- Click the _Publish OAuth app_ button
- Check that both options in the _Authorization_ section require a
confirmation with a checkbox
- Before submitting, open your devtool
- Submit the app
- Check that the API route
`https://api.supabase.green/platform/organizations/[org_slug]/oauth/apps`
was called with the options you selected:
- if _Use the permissions of the person who connects_ was checked:
`grant_kind: "member_bound"`, otherwise `grant_kind:
"organization_bound"`
- If _Ask for specific projects_ was checked: `project_scoping_mode:
true` otherwise `project_scoping_mode: false`
2026-11-17 16:35:32 +01:00
Alaister YoungandAlaister Young bbb0af65cb [FE-3106] (part 14) – refactor(studio): drop the dual-runtime shims and aliases (#53223)
Drops the remaining Next-era shims and aliases that only existed for the
dual runtime (FE-3106). Part 14 of the stack.

**Depends on:** #53222

**Changed:**
- ~45 files – import Sentry from `@sentry/react` directly instead of the
aliased `@sentry/nextjs`
- `hooks/ui/usePreventNavigationOnUnsavedChanges.ts` – is now the
TanStack `useBlocker` implementation (previously swapped in by a Vite
alias)
- `components/interfaces/App/RouteValidationWrapper.tsx` – `next/router`
→ `useNavigate` + the leaf route's `fullPath` (`/project/$ref/sql/$id`)
for the exempt-route and last-visited checks
- `hooks/misc/withAuth.tsx` – no `getLayout` forwarding
- `TemplateEditor.test.tsx` – renders inside a router for the
unsaved-changes blocker

**Removed:**
- `compat/sentry-nextjs.ts` and its Vite alias, the
`usePreventNavigationOnUnsavedChanges` alias and Next hook,
`types/next.ts` (`NextPageWithLayout`), the `@sentry/nextjs` dependency

The `compat/next/*` shims for `link`, `router`, `head`, `image`,
`navigation`, `dynamic` and `script` stay: about 300 components outside
`routes/**` still import them.

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Trigger an error (e.g. a failing query) – it reaches Sentry as before
- Edit an email template or edge function and navigate away – the
unsaved-changes prompt appears
- Open an org you don't belong to – toast and redirect home; open a SQL
snippet, leave and come back – last snippet is restored

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 17:49:20 +09:00
Riccardo Busetti 2a9b02a99a feat(docs): Improve Pipelines docs and UI (#53450) 2026-11-16 16:25:00 +00:00
Drew McLellan f7f27aac78 fix(studio): escape json and jsonb values in SQL copy and export (#53372)
## What

Fixes invalid or corrupted SQL from "Copy rows as SQL" and "Export table
as SQL" for json/jsonb columns (FE-4860, closes #49196).

## Why

The SQL formatter built json literals by rewriting `JSON.stringify`
output with regexes. That corrupted values containing double quotes or
backslashes, and produced invalid SQL for jsonb columns holding plain
strings or other non-object values.

## How

- `formatTableRowsToSQL` now serializes the parsed value and only
escapes single quotes.
- Grid rows carry json columns as text (the grid query casts them to
`::text`), so a new `parseGridJsonColumns` helper parses untruncated
json cells before formatting. It is used by "Copy rows as SQL" and the
selected-rows export. Truncated cells are left alone so they are still
fetched in full.
- The SQL export keeps json columns unstringified
(`preserveJsonValues`), so a jsonb string like `"hello"` stays
distinguishable from JSON text. CSV and JSON exports are unchanged.

No `::text` cast was added to the export query: the API already returns
json values parsed.

## Testing

- Unit tests for values with `"`, `\`, `'`, plain-string jsonb, arrays,
numbers, booleans and null, plus `parseGridJsonColumns`.
- Ran the formatter output against a local Postgres: both the parsed
(fetch-all) and grid-text (copy / selected rows) shapes loaded and
round-tripped identically for jsonb and json columns. The old
formatter's output failed with `invalid input syntax for type json` on
the same data.
- Not exercised end to end in the Studio UI, and the truncated-cell path
is covered by unit tests only.

## Not in scope

The JSON export still stringifies objects before `JSON.stringify`, so
json columns come out as nested strings. That is separate pre-existing
behavior.
2026-11-16 13:52:05 +00:00
311e2c721c fix(studio): suggest cli download when function code exceeds max size limit (#53421)
<!-- claude-slack-attribution -->
_Requested by **Kalleby Santos** · [Slack
thread](https://supabase.slack.com/archives/C02KMRX22NR/p1794750855761849?thread_ts=1794750855.761849&cid=C02KMRX22NR)_

## Problem

**Before:** When an Edge Function's source is too large to load in
Studio, the function's Code tab shows "Failed to load function code"
with the same steps as any other load failure: update the CLI, then
redeploy with `supabase functions deploy` or use the Management API.
Redeploying does not help here, because the problem is the size of the
code, not a bad deployment.

**After:** When the function body request fails because the code exceeds
the maximum size (HTTP 507), the same error screen tells the reader to
update the CLI and then download the function with `supabase functions
download <function-slug>`. All other load errors keep the existing
redeploy and Management API steps.

## Solution

Adds `isFunctionBodyMaxSizeError` (true when the error code is 507) next
to the function body query, and the Code page uses it to pick which step
2 to show. Studio already preserves the HTTP status as `error.code`, so
no changes to error classification are needed.

This ports Kalleby's fork commit
[498a1b1](https://github.com/kallebysantos/supabase/commit/498a1b1b386accea4fa57a85a3a2328b79a3b34c)
onto current master. Differences from the original: it types the helper
against Studio's current error shape instead of `ResponseError`, fixes
the "Donwload" typo, and adds a small unit test for the helper.

Co-authored-by: Kalleby Santos <kalleby_santos@hotmail.com>

## Review instructions

1. Open a function's Code tab where the function body request returns
507 (for example by mocking the response) and confirm step 2 reads
"Download your function using: `supabase functions download <slug>`"
with no Management API step.
2. Trigger any other body load error and confirm the redeploy and
Management API steps are unchanged.

## Checklist

- [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 (not applicable, no docs
changes)

---
_Generated by [Claude
Code](https://claude.ai/code/session_01JZqbAVr5Epmzu7mKWMj9jD)_

---------

Co-authored-by: Kalleby Santos <kalleby_santos@hotmail.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-11-16 12:08:27 +00:00
Joshen Lim 4ed3627d72 Joshenlim/fe 3891 improve handling of partition tables in (#53268)
## Context

The Table Editor doesn't really handle partitioned tables well given the
following issues:
- Partitioned tables are rendered as a flat list in the Table Editor
side menu, so the menu could get very long and noisy - this was the
primary motivation for this PR
- Child partitioned tables are not indicated with a proper icon, they're
treated as regular tables in the Table Editor which is incorrect

## Changes involved
- Table Editor side menu now only lists parent partitioned tables, omits
all child partitioned tables
- Child partitioned tables can be viewed by clicking on the button
tooltip here or drilling down via "View partitions"
<img width="300" alt="image"
src="https://github.com/user-attachments/assets/e3cfbe4b-21ff-47df-8fcd-81d0c9f68d94"
/><br />
<img width="400" alt="image"
src="https://github.com/user-attachments/assets/5d0747cb-fb52-4301-ad9e-c7be504f43c9"
/>

  - Selecting that will then render a nested nav as such
<img width="291" height="323" alt="image"
src="https://github.com/user-attachments/assets/bff0a42b-4265-4317-8299-537d82544388"
/>

- Sub partitioned tables can be drilled into the same way, and the back
CTA steps up one level
<img width="485" height="306" alt="image"
src="https://github.com/user-attachments/assets/66f6f6cb-8b7d-46c5-8ea3-4ee4fd57aa84"
/>

- Parent partition tables have the following actions (Previously was
only copy name and schema)
<img width="465" height="257" alt="image"
src="https://github.com/user-attachments/assets/2aa90995-7c30-4bcf-a446-d01ab52c1ede"
/>

- Deleting a parent partition table will also delete the child partition
table, and that's highlighted in the confirmation modal
<img width="418" height="316" alt="image"
src="https://github.com/user-attachments/assets/0d61984b-f85e-4c93-84d0-549d300838c9"
/>

- Child partition tables have the following actions (Edit + duplicate
removed since they aren't supported via the UI)
<img width="482" height="229" alt="image"
src="https://github.com/user-attachments/assets/e028b13d-2e92-4491-b05c-7a6cb0a129d6"
/>


## To test
In general, just verify the viewing UX of partitioned tables to see if
it all feels alright, can use the following SQL to quickly set up
partitioned tables
```sql
   create schema if not exists tint;
   create table public.nest_demo (id int, hue int not null, primary key (id, hue))
     partition by range (hue);
   create table public.nest_demo_blue partition of public.nest_demo
     for values from (200) to (300) partition by range (hue);
   create table public.nest_demo_blue_light partition of public.nest_demo_blue
     for values from (200) to (250);
   create table tint.nest_demo_blue_deep partition of public.nest_demo_blue
     for values from (250) to (300);
   create table public.nest_demo_other partition of public.nest_demo
     for values from (0) to (200);
   ```
2026-11-16 17:23:59 +07:00
Joshen Lim f4d8252427 Improve postgres upgrade warning for pipelines (#53359)
## Context

For upgrading a project's Postgres version, the eligibility check
returns blockers if a project has active pipelines running. However, the
notices are currently confusing and not actionable from a user's POV for
these reasons:
- The warnings mention the slot name in the title, but as a user i've no
idea what slot names these are referring to
- There's no CTA as a user to action on to unblock myself
- There's multiple warnings due to each replication slot that the
pipelines take up, although they all point to the same reason that
pipelines just needs to be stopped before upgrading
- Example here if i have 3 active pipelines: I get 10 warnings here
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/c4d99cd4-df3b-4e8e-90cd-896c0f2fa52b"
/>

Am opting to consolidate all Pipelines related upgrade warnings into
just one row as such, by grouping them if the upgrade eligibility error
type is `active_replication_slot` and the slot name begins with
`supabase_etl_`. Added a "Manage" CTA as well that brings users to the
Pipelines page
<img width="799" height="234" alt="image"
src="https://github.com/user-attachments/assets/50a0c64a-6afe-44e2-9bf8-a21e8ecfc47a"
/>

Also small nit but this PR fixes the weird list decorator in the rows
too
<img width="165" height="81" alt="image"
src="https://github.com/user-attachments/assets/8c0a0ff6-225f-48d1-a25f-8ffa9e65533c"
/>
2026-11-16 10:50:47 +07:00
Pamela Chia 4998b77ab2 feat(studio): ask whether org creators know how to code (#53317)
I added the "Do you know how to code?" question (Yes / No, optional) to
the onboarding survey on the new organization form and in the follow-up
dialog. The answer is sent as `can_code` in the same survey request as
the other answers. I removed an earlier version of this question before
the survey shipped because the platform didn't store it; the platform
now accepts `can_code`.

**Changed:**
- **New question, always visible**: it shows on both surfaces without
waiting on another answer, so it can be answered on its own. Only the
`org_form` arm of the experiment shows the survey.
- **Follow-up dialog shows every question at once**: "What are you
building?" used to appear only after "Who is this org for?" was
answered. "How many people?" still appears only for the Company org
type.
- **Follow-up card above other banners**: I raised its priority in the
banner stack so it sits in front of the project-page cards for its
five-minute window.
- **Telemetry**: I added a `hasCanCode` boolean to
`onboarding_survey_submit_button_clicked` and
`onboarding_survey_submit_failed`.

**Note:** Merge only after the platform change that accepts `can_code`
is in production: before that, the API drops the key and still returns
204, so answers are lost with no error. The change is live once
`can_code` is listed under `OnboardingSurveyBody` in the production
platform OpenAPI spec. I widened `OnboardingSurveyBody` locally because
`packages/api-types` can only be regenerated once the production spec
has the field.

## To test
Setup: sign in and set the `onboardingSurveyPlacement` flag to
`org_form` with the dev toolbar.

Tested on the PR preview:
- [x] Open `/new`: expect "Do you know how to code?" below "What are you
building?" with Yes then No, before any other question is answered.
Answer both and create the org: expect one `POST
/platform/organizations/onboarding-survey` whose body has `building` and
`can_code`. Observed: both questions on the untouched form, options Yes
then No; one request, 204, body has `"can_code":"yes"`.
- [x] Create an org with only "Do you know how to code?" answered:
expect one request whose body has `can_code` and no `building` key.
Observed: one request, 204, `"can_code":"no"`, no `building` key, and no
follow-up card on the new org's page.
- [x] Create an org with the org type changed to Company, a size picked
and "Do you know how to code?" answered, leaving "What are you
building?" blank: expect one request with `kind`, `size` and `can_code`,
and no follow-up card on the new org's page. Observed: one request, 204,
`"kind":"COMPANY","size":"50","can_code":"yes"`; no follow-up card.
- [x] Create an org with "What are you building?" answered and the new
question left blank: expect the request body to have no `can_code` key,
and the org to be created. Observed: one request, 204, no `can_code`
key.
- [x] Create an org without touching the survey, then open the new org's
page: expect the "Help improve Supabase" card. Click Answer: expect all
three questions in the dialog right away. Answer all three questions and
send: expect one request with `kind`, `building` and `can_code`.
Observed: no survey request at creation; the card shows on the org page;
the dialog opens with all three questions blank; one request, 204, body
has `"can_code":"yes"`.
- [x] Set the flag to `control` and open `/new`: expect no survey
questions. Observed: none of the survey questions render.
- [x] Added check: `onboarding_survey_submit_button_clicked` carries
`hasCanCode`. Observed: `true` when answered on both surfaces, `false`
when left blank.

## Linear
- fixes GROWTH-1487
2026-11-13 23:14:29 +09:00
kemal.earth f1d9d3a96a feat(studio): add saved views in unified logs (#53286)
Persist saved views through project-scoped content endpoints. Restore custom attribute filters and saved options, and validate content with focused Zod schemas.
2026-11-13 14:55:26 +01:00
Charis b046f12571 chore(api-types): update generated API types from production (#53364)
Regenerates the API types with `pnpm api:codegen:prod` and fixes the
Studio type errors the new types caused.

## Changes from the API

- **Branch merge now requires production write permission.** `POST
/v1/branches/{branch_id_or_ref}/merge` changed from accepting either
`branching_development_write` or `branching_production_write` to
requiring `branching_production_write`. Studio's FGA refinement for
merge no longer matched and failed typecheck.
  - Removed the merge entry from `lib/fga-refinements.ts`.
- `merge.tsx` checks merge permission with `useGrant` instead of
`useBranchGrant`.
  - `BranchMergeGrant` uses `GrantFor` instead of `GrantForVariants`.
- Removed merge from the "requires a variant" test in
`guarded-fetch.test.ts`.
- Users with only development branching permissions can no longer merge
in Studio. This matches what the API now enforces.
- **Replication pipelines have a required `cluster_id`.** Added it to
the pipeline fixtures in six test files.
- **`MemberWithFreeProjectLimit` has a required
`free_plan_organizations`.** Added it to the mock in
`tests/pages/new/[slug].test.tsx`. No app code reads it yet.

## Testing

- `pnpm typecheck` passes.
- Vitest passes for the affected Studio tests.
2026-11-13 08:02:50 -05:00
Charis ed6d1b4c63 feat(studio): show error details in AlertError and attribute user faults in SQL errors (#53242)
## Problem

`AlertError` gives users and support no way to correlate a failure with
Sentry or platform logs. It also treats every failure the same: a bad
table editor filter or an offline browser gets "try refreshing, contact
support".

On the reporting side, SQL errors were attributed by who wrote the whole
statement. That made errors in the user's part of mixed SQL Studio's
fault: policy expressions, function bodies, cron schedules, table editor
filters and row edits. Marking them as user SQL instead would drop them
from Sentry entirely.

Part of FE-4772.

## Solution

**`AlertError`**
- Platform and Studio faults show the request ID, the Sentry event ID
(labeled "before sampling", since the event may be sampled out) and a
"Copy details" button.
- The copied text never includes `formattedError`, metadata, the cause
or SQL.
- SQL errors copy the SQLSTATE, position and query name instead of the
message.
- User faults (`isUserError`) show their message with "Please try again.
If the issue persists, try refreshing your browser." There is no support
link, no IDs and no copy button.
- Offline shows only "You may be temporarily offline. Check your
internet connection and try again."
- Defaults come from `getErrorPresentation`, and props the caller passes
still win. The table editor passes a filter-specific description when
filters are set.

**SQL error classification**
- `executeSql` takes an optional `isUserFaultSqlState` predicate for
Studio SQL. When it matches, the error is a `StudioSqlError` with reason
`user_input` and fault `user`, and is still redacted to SQLSTATE plus
query name.
- `isUserFaultForValues` (classes 22, 23 and P0, plus 42501 and 57014)
is for typed values: table editor filters and row edits, cron name and
schedule.
- `isUserFaultForSql` (any SQLSTATE except server classes 08, 53, 57
other than 57014, 58 and XX) is for embedded user SQL: policies,
functions, the custom access token hook.
- `isUserFaultForStatsStatement` is for `pg_stat_statements` text (Query
Insights `EXPLAIN`, index advisor). It treats 42P02 (`$1` placeholders)
as Studio's fault.
- `UserSqlError` is now only SQL the user wrote in full, and it is still
never sent.
- The policy, function and cron mutation hooks no longer take
`sqlOrigin`.

**Routing and types**
- `ERROR_ROUTING` is one table keyed by tag, then by fault. Its type
requires exactly the faults each class can produce.
- User faults get `SAMPLE_USER_FAULT` (default 0.01, set with
`NEXT_PUBLIC_SENTRY_SAMPLE_RATE_USER_FAULT`) to catch misclassification.
- The error class decides privacy (`isNeverReportedError`), separately
from the rate.
- Sentry events get a `reason` tag.
- Each class declares its `reasons`, so a mistyped reason fails
typecheck.

## Review instructions

1. Open the table editor, add a filter with a wrong-typed value (text on
an integer column). The alert shows the Postgres error, the filter hint,
and no support link, IDs or copy button.
2. Make a query fail with a platform error (e.g. block a `/platform/`
request in DevTools). The alert shows the request ID, the event ID and
"Copy details". Paste the copied text and check it has no SQL or
`formattedError`.
3. Go offline in DevTools and trigger a query. Only the offline message
shows.
4. Create a policy with an invalid `USING` expression. The toast shows
the Postgres error. In Sentry it is a `StudioSqlError` with reason
`user_input`, sampled at the user-fault rate.
5. Review `lib/errors/error-routing.ts` and
`data/error-classification.ts` for the routing table and the SQLSTATE
predicates.
2026-11-12 15:19:25 -05:00
Charis 115a2ffeef feat(studio): gate database functions, triggers, and webhooks on sql grants (#53269)
Resolves FE-4744. Part of the grants rollout; builds on the read/write
SQL variants from #53185.

## What

- **Data layer:** the database functions, triggers, database webhooks,
and event triggers queries now take a `read` grant (exposed as
`queryOptions` factories). All 8 create/update/delete mutations take a
`write` grant and mark their SQL with `asWriteSql`.
- **Guards:** the hand-written FGA checks in the functions, triggers,
event triggers, and database webhooks lists, the functions page, the
triggers layout/route, and the webhooks integration tab now derive from
grants, with denied and error states.
- **Other consumers** updated to pass grants: `CreateFunction`,
`TriggerSheet`, `EditHookPanel`, `DeleteHookModal`,
`ChooseFunctionForm`, `FunctionSelector`, `AutoEnableRLSNotice`, and SQL
editor definition/autocomplete hooks.

## Behavior changes

- **Webhooks integration tab:** was gated on
`database_webhooks_config_read`; now gated on `database_read`, which is
what the backend checks for the pg-meta query it uses. Both permissions
are granted to the same built-in roles, so there is no change for
built-in roles. A permissions-load failure now shows an error alert
instead of the content.
- **`AutoEnableRLSNotice`:** hidden unless the user has read access,
since it can't tell whether the trigger already exists without it.

## Out of scope

- User-authored SQL execution in `QueryEditor` / `useSqlEditorExecution`
stays `unguarded.migrating` (FE-4750).

## Testing

- New tests: query factories and write mutations
(`data/database-sql-grants.test.ts`), webhooks tab granted/denied/error,
functions list read/write granted/denied/error.
- Typecheck, Prettier, lint ratchet, and Studio vitest suites for
affected areas pass.
2026-11-12 14:58:01 -05:00