Skip to content

feat: table for collecting interfaces feedback - #48420

Merged
kanadgupta merged 11 commits into
masterfrom
kanad-2026-07-28/interfaces-feedback-table-take-2
Aug 19, 2026
Merged

kanadgupta merged 11 commits into
masterfrom
kanad-2026-07-28/interfaces-feedback-table-take-2

Conversation

@kanadgupta

@kanadgupta kanadgupta commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Database migration — adds a table for collecting free-form product feedback submitted from Supabase interfaces (starting with the CLI and the MCP server), including support for deleting a submission via a server-issued token.

What is the current behavior?

There is no destination for feedback submitted from the CLI or MCP server. The existing feedback and feedback_comments tables are scoped to the docs feedback widget, so interface feedback would otherwise end up as ad-hoc GitHub issues — with no way to revoke something submitted by accident (e.g. a secret key pasted into the message).

What is the new behavior?

Adds public.interfaces_feedback:

Column Type Notes
id bigint identity primary key (not exposed through the API)
created_at timestamptz not null default now()
feedback text not null, ≤ 1000 chars — the free-form feedback
delete_token uuid server-generated, unique not null; authorizes deleting the row
user_agent text ≤ 255 chars; interface + version, also identifies the source interface
user_id text optional, ≤ 255 chars; unverified, interface-defined identifier
project_ref text optional, ≤ 255 chars
metadata jsonb ≤ 8 KB catch-all

Submission happens exclusively through a SECURITY DEFINER function, submit_interfaces_feedback(...), which inserts the row and returns the server-generated delete_token exactly once. There is no insert grant or policy on the table itself, so clients cannot insert directly or supply their own token — the function is the only door. Execute is revoked from PUBLIC and granted to anon only (both statements matter: local and hosted databases have different default function ACLs).

Deletion is a hard DELETE authorized by presenting the token in an x-feedback-token request header. RLS policies compare the row's delete_token against that header (current_setting('request.headers', ...)) — the URL filter is never the security boundary; a request without the matching header affects zero rows, even with no filter or someone else's token in the filter. Tokens never expire (the delete right shouldn't lapse). The header is cast to uuid and compared against the untransformed column, so lookups use the unique index on delete_token even for header-only reads; a malformed token header is rejected with a 400 (22P02), consistent with what a malformed URL filter value already returns.

Context gate (defense-in-depth): rows submitted with a project_ref and/or user_id additionally require the matching x-feedback-project-ref / x-feedback-user-id headers — on both reads and deletes — so a leaked bare token can neither read the submission text back nor remove the row. A NULL column imposes no requirement: context-free rows keep token-only behavior, and extra headers sent against them are ignored (this keeps clients that always send their current context from being locked out of rows submitted without it). These are client-supplied, unverified values, so the gate is a knowledge factor rather than an identity check; clients should persist {delete_token, project_ref, user_id} together at submit time and re-present them byte-exact (project_ref/user_id are compared as plain text).

Reads are limited to grant select (feedback, delete_token) behind the same token-scoped policy: a token-holder can preview their own submission text before deleting and confirm the delete matched (Prefer: count=exact → Content-Range: */1 vs */0). No other columns are readable by any API role; delete_token needs select because PostgREST requires a WHERE clause on deletes and filter columns require select privilege.

Verified locally via supabase db reset + the local REST API: token issuance, token-scoped preview and delete, zero-row results for missing/wrong/malformed tokens (including a victim's token in the filter without the header), the full context-gate matrix (project+user, project-only, and context-free rows, incl. lenient extra-header behavior), denied direct inserts and column reads, length caps enforced through the function, and no execute for authenticated.

Additional context

Linear tickets: CLI-1946, CLI-1999

The client-side flows (supabase feedback add / feedback delete in the CLI, and the MCP tool) land separately in their respective repos and will call the RPC / DELETE endpoint described above.

Supersedes #48378 — recreated on a fresh git branch so that the Supabase preview branch used for testing this table isn't shared with unrelated work.

Summary by CodeRabbit

  • New Features
    • Added support for collecting and storing feedback submitted through interfaces.
    • Feedback can include submission source, timestamps, user details, project references, and additional metadata.
    • Added secure feedback submission with controlled access to protect submitted information.
    • Added support for authorized feedback removal using a secure deletion token.
    • Added safeguards to validate feedback content and restrict access to permitted information.

@vercel

vercel Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview Aug 18, 2026 8:15pm
docs Ready Ready Preview, v0 Aug 18, 2026 8:15pm
studio-self-hosted Ready Ready Preview Aug 18, 2026 8:15pm
studio-staging Ready Ready Preview Aug 18, 2026 8:15pm
ui-library Ready Ready Preview Aug 18, 2026 8:15pm
zone-www-dot-com Ready Ready Preview, v0 Aug 18, 2026 8:15pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 18, 2026 8:15pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e8f85534-9fca-4bea-ab56-dc1a526166da

📥 Commits

Reviewing files that changed from the base of the PR and between 4dfe753 and e6891f3.

📒 Files selected for processing (1)
  • supabase/migrations/20260728035858_create_interfaces_feedback.sql

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Adds a Supabase migration for interfaces_feedback. The migration defines constrained feedback storage, a security definer submission function, a generated deletion token, and header-based anonymous select and delete policies.

Changes

Interfaces feedback access flow

Layer / File(s) Summary
Feedback schema and submission function
supabase/migrations/20260728035858_create_interfaces_feedback.sql
Creates interfaces_feedback with constrained feedback and metadata fields. Adds public.submit_interfaces_feedback, which inserts rows and returns the generated delete_token. Restricts function execution to anon.
Header-based feedback access
supabase/migrations/20260728035858_create_interfaces_feedback.sql
Enables RLS and limits anonymous select and delete operations to matching deletion-token, project-reference, and user-ID headers when applicable. Grants column-scoped select and delete access.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to e6891

This migration adds the feedback storage and token-scoped access behavior described in the PR; no actionable merge-blocking risk remains based on the supplied evidence.

Sequence Diagram(s)

sequenceDiagram
  participant AnonymousClient
  participant submit_interfaces_feedback
  participant interfaces_feedback
  AnonymousClient->>submit_interfaces_feedback: Submit feedback and optional metadata
  submit_interfaces_feedback->>interfaces_feedback: Insert feedback row
  interfaces_feedback-->>submit_interfaces_feedback: Generate delete_token
  submit_interfaces_feedback-->>AnonymousClient: Return delete_token
Loading

Suggested reviewers: gregnr, lukas-bernert, charislam

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding a table to collect interface feedback.
Description check ✅ Passed The description includes all required sections and provides detailed behavior, testing, context, and related ticket information.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kanad-2026-07-28/interfaces-feedback-table-take-2

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

❤️ Share

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

@supabase

supabase Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Updates to Preview Branch (kanad-2026-07-28/interfaces-feedback-table-take-2) ↗︎

Deployments Status Updated
Database ✅ Tue, 18 Aug 2026 20:20:31 UTC
Services ✅ Tue, 18 Aug 2026 20:20:31 UTC
APIs ✅ Tue, 18 Aug 2026 20:20:31 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations ✅ Tue, 18 Aug 2026 20:20:32 UTC
Migrations ✅ Tue, 18 Aug 2026 20:20:34 UTC
Seeding ✅ Tue, 18 Aug 2026 20:20:34 UTC
Edge Functions ✅ Tue, 18 Aug 2026 20:20:36 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@kanadgupta kanadgupta changed the title feat: table for collecting interfaces feedback (take 2) feat: table for collecting interfaces feedback Jul 29, 2026
@kanadgupta
kanadgupta marked this pull request as ready for review July 29, 2026 04:12
@kanadgupta
kanadgupta requested review from a team, charislam, gregnr and mattrossman July 29, 2026 04:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@supabase/migrations/20260728035858_create_interfaces_feedback.sql`:
- Around line 25-35: Restrict the “Anyone can insert interfaces feedback” policy
and its explicit INSERT grant to the anon role only. Update the policy target
and grant in the interfaces_feedback migration, while leaving the service_role
SELECT grant unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2bc2e60f-cf32-4173-8812-9edb17ed85d3

📥 Commits

Reviewing files that changed from the base of the PR and between 5712eef and 195071c.

📒 Files selected for processing (1)
  • supabase/migrations/20260728035858_create_interfaces_feedback.sql

kanadgupta and others added 4 commits July 29, 2026 15:44
Addresses PR review feedback on the interfaces_feedback table:
- remove source (interface is identified via user_agent instead)
- cap feedback (1000 chars), user_agent/project_ref (255), metadata (8 KB)
- restrict the insert policy and grant to the anon role, since clients
  submit with the publishable key only

Co-Authored-By: Claude Fable 5 <[email protected]>
Matches the other feedback tables, which have no service_role grant —
feedback is read via direct database access, not the REST API.

Co-Authored-By: Claude Fable 5 <[email protected]>
@kanadgupta

This comment was marked as resolved.

@kanadgupta
kanadgupta marked this pull request as draft July 31, 2026 15:00
kanadgupta and others added 3 commits August 11, 2026 15:06
Submissions now go exclusively through a security definer RPC
(submit_interfaces_feedback) that returns a server-generated delete
token exactly once. Presenting the token via the x-feedback-token
header authorizes reading back and hard-deleting that row through
header-checked RLS policies; the direct insert path is removed so
client-supplied tokens are impossible by construction.

delete_token is included in the column select grant because PostgREST
rejects filterless deletes and WHERE columns require select privilege;
clients send the token as both filter and header, and the RLS policy
remains the security boundary.

Co-Authored-By: Claude Fable 5 <[email protected]>
Defense-in-depth on the delete-token model: rows submitted with a
project_ref and/or user_id now additionally require the matching
x-feedback-project-ref / x-feedback-user-id headers on both select and
delete. A null column imposes no requirement, so context-free rows keep
token-only behavior and extra headers are ignored (lenient semantics —
a client that always sends its current context can still delete rows
submitted without it).

Co-Authored-By: Claude Fable 5 <[email protected]>
@kanadgupta
kanadgupta marked this pull request as ready for review August 17, 2026 16:59
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@kanadgupta
kanadgupta requested review from charislam and gregnr August 17, 2026 17:01
Compare delete_token as uuid (header cast to the column's type) instead
of casting the column to text, so token lookups use the unique index —
header-only reads were seq-scanning, which matters since table growth is
attacker-influenced. A malformed token header is now rejected with a 400
(22P02), consistent with what a malformed URL filter already did.

Widen user_id to capped text: it is an unverified, interface-defined
identifier (nothing sends it yet), so locking it to uuid constrained
future interfaces for no security benefit. Context-gate values must be
re-presented byte-exact.

Co-Authored-By: Claude Fable 5 <[email protected]>
@kanadgupta
kanadgupta requested a review from a team August 18, 2026 22:28
@kanadgupta

kanadgupta commented Aug 19, 2026 •

Copy link
Copy Markdown
Member Author

I'm ready to merge this but I have a couple outstanding questions that I posted here. Will merge this once those questions are addressed.

@joshenlim joshenlim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving to unblock!

@kanadgupta
kanadgupta merged commit 1b01a9c into master Aug 19, 2026
36 of 38 checks passed
@kanadgupta
kanadgupta deleted the kanad-2026-07-28/interfaces-feedback-table-take-2 branch August 19, 2026 17:32
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1787160995)

pull Bot pushed a commit to oogalieboogalie/cli that referenced this pull request Sep 10, 2026
supabase#5988)

## What

Adds a TS-only `supabase feedback` command family (from the [original
brainstorm](https://supabase.slack.com/archives/C0BAGJBL49E/p1784320045234149))
so users — and agents — can send quick, low-friction feedback to the
Supabase team without filing a GitHub issue, and revoke a submission
later (e.g. an accidentally pasted secret):

```sh
supabase feedback add "when I run multiple stacks in parallel I get port conflicts"
# → Thanks for the feedback!
# → To delete this feedback later, run: supabase feedback delete <token>

supabase feedback delete 123e4567-e89b-12d3-a456-426614174000
```

Part of [CLI-1946](https://linear.app/supabase/issue/CLI-1946); the
delete command is
[CLI-2188](https://linear.app/supabase/issue/CLI-2188). Scope evolved in
[this
thread](https://supabase.slack.com/archives/C07E5GFAHTM/p1785303671170249):
`feedback add` (no `btw` alias) plus a token-based delete path, rather
than full user-scoped CRUD.

## How `feedback add` works

- **Message resolution**: positional args → piped stdin (non-TTY) →
interactive prompt (TTY, text mode) → error. Messages starting with a
dash use the `--` sentinel. Piped stdin is read in constant memory with
a 64 KB cap; a read error mid-pipe discards the partial buffer rather
than submitting a truncated message. Messages over the 1000-character
limit are rejected client-side (counted in code points, matching
Postgres `char_length`).
- **Transport**: submits through the `SECURITY DEFINER` RPC
`submit_interfaces_feedback` (supabase/supabase#48420) via `supabase-js`
— the table has no insert grant, so the RPC is the only door and the
delete token is always server-generated. The committed keys are
publishable (anon) keys, safe to ship in the binary. 10s timeout.
- **Delete token**: the RPC returns a uuid `delete_token` exactly once.
Text mode prints it with a "to delete this later" hint (including
`--project-ref <ref>` when the submission carried one, since the row can
only be deleted with that ref presented); `json`/`stream-json` carry it
as `delete_token` in the result payload. The CLI never persists it.
- **Submission context**: CLI version, user agent, OS/arch, agent
detection (`is_agent`/`agent_name` via `@vercel/detect-agent`, to
support the activation analysis in AI-961), and the linked project ref.
`metadata.source: "cli"` distinguishes CLI rows from the future MCP
path. The access token is never sent. The persisted gotrue user id
(`distinct_id` in `telemetry.json`, stamped at login) is sent as
`user_id` **only** when the user is logged in and telemetry consent is
granted — best-effort attribution; logged-out or opted-out runs omit it.
A row submitted with a `user_id` can only be deleted by the same
account.
- **Project ref resolution**: `SUPABASE_PROJECT_ID` →
`<workdir>/supabase/.temp/project-ref` (the file `supabase link` writes)
→ omitted. A malformed `SUPABASE_PROJECT_ID` fails with the shared
invalid-ref error, like every other command's explicit ref. The file is
read directly (not via `ProjectRefResolver`, whose prompt path needs the
platform API) so feedback works logged-out; a broken or malformed ref
file degrades to "unlinked".
- **Environments**: the feedback backend follows the resolved profile
the same way the Management API URL does.
`supabase-staging`/`supabase-local` post to the persistent staging
branch of the feedback project; every other profile (including YAML-file
profiles) posts to the production feedback project. Connection constants
live in `src/shared/feedback/feedback-client.layer.ts`.

## How `feedback delete <token>` works

- **Validation**: the token must be a UUID (checked client-side to avoid
PostgREST's cryptic uuid-cast error) and is lowercased before sending.
- **No read, ever**: the CLI never fetches the feedback text. Deleting
is harmless to the user (the row exists for Supabase's benefit), so
nothing is shown first; the only request is the DELETE below. With no
client reading rows, the backend's anon read path has nothing to serve
and is removed in a follow-up
([CLI-2406](https://linear.app/supabase/issue/CLI-2406)). The delete
policy is unchanged.
- **Confirmation**: interactive text mode prompts (`Permanently delete
this feedback? [y/N]`) as the guard against a mistyped or pasted token;
`--yes`/`SUPABASE_YES` skips it. The prompt runs before the row's
existence is known, so a wrong token gets the prompt and then the
not-found error. Machine modes (`json`/`stream-json`, and `-o json`)
fail loudly without `--yes` rather than deleting silently — same
contract as `logout`. Both stdin and stdout must be TTYs for the prompt,
so `printf 'y' | supabase feedback delete <token>` cannot confirm a
delete without `--yes`.
- **Deletion**: a hard `DELETE` with `Prefer: count=exact`; the CLI
verifies `Content-Range` reports exactly one row. Zero rows → a friendly
not-found error covering all three indistinguishable causes (wrong
token, already deleted, project-ref/user-id context mismatch).
Authorization is the `x-feedback-token` request header matched by RLS —
the `delete_token=eq.` URL filter only satisfies PostgREST's
filterless-delete rejection. `--debug` request lines redact the filter.
- **Context gate**: rows submitted from a linked project also require
the matching `x-feedback-project-ref` header, and rows submitted while
logged in require `x-feedback-user-id`. The delete command resolves the
ref as `--project-ref` → `SUPABASE_PROJECT_ID` → linked-ref file (flag
and env validated, file soft) and always sends whatever resolves (extra
context against a context-free row is ignored server-side). The user-id
header is not consent-gated: it is functional auth context, and gating
it would strand rows submitted before an opt-out.
- Machine modes return an acknowledgement only: `--output-format json`
gives `{ "message": "Feedback deleted." }`, `-o json` gives `{
"deleted": true }`.

## Privacy note for reviewers

The feedback message, the delete token, and the `--project-ref` value go
**only** to the feedback backend — never to PostHog. Message and token
are positional arguments, which `extractChangedFlagNames` structurally
excludes from the `flags` telemetry property; `--project-ref` is
recorded by name only with its value redacted. Regression tests assert
none of them appear in captured analytics events. `user_id` is sent to
the feedback backend under the conditions above and is documented in
`add/SIDE_EFFECTS.md`.

## Reviewer-relevant context

- The shared service was reshaped from `FeedbackSubmitter` (insert-only)
into `FeedbackClient` (`submit`/`delete`) in
`src/shared/feedback/feedback-client.{service,layer}.ts`, and the
profile→environment mapping and cli-config layer wiring were hoisted to
the feedback family root (`feedback.layers.ts`,
`feedback-project-ref.ts`) now that two commands share them.
- `FeedbackBackendError` carries a `reason` (`response` vs `transport`)
so a PostgREST rejection classifies as `apiStatus` in error telemetry
while network failures stay `externalNetwork`. postgrest-js reports
fetch rejections, timeouts, and aborts as an error envelope with
`status: 0`, which is the discriminator.
- The feedback client speaks `fetch` (supabase-js), not Effect's
`HttpClient`, so `--debug` logging and `--dns-resolver https` compose at
the fetch boundary (`feedbackFetch`). Along the way the shared DoH
wrapper gained two fixes that apply to every command: WHATWG `Headers`
instances survive the rewrite, and the request's abort signal now
cancels the DoH lookup itself.
- `src/shared/feedback/database.types.ts` is generated (`pnpm
gen:feedback-types`, from the production project) and excluded from
formatting/knip; it is marked `linguist-generated`.
- The real-backend golden path (add → delete round trip against the
staging branch, cleaning up its own row) is `add.live.test.ts` under the
gated live project. The default e2e file only exercises subcommand
routing with zero network.
- The commands are registered in `docs-spec.tables.ts` (`other-commands`
tag) and each has a `SIDE_EFFECTS.md`.
- **Heads-up on `CommandSettings.projectId`**: it is a bare
`SUPABASE_PROJECT_ID` env passthrough — it does not read `config.toml`
or the linked-project file, so it is `None` in a linked project unless
that env var is set. An earlier revision of this branch used it directly
as "the linked project ref", which meant `project_ref` was always `null`
in practice. The agent-guide row that described it as resolving
project-id from `config.toml` was corrected here, since that phrasing is
what made the field look project-aware.
- `services.integration.test.ts` now uses an isolated temp workdir
instead of `process.cwd()`, fixing machine-dependent behavior when the
developer has local `supabase start` state.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: Colum Ferry <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants