Repository navigation
feat: table for collecting interfaces feedback - #48420
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughAdds a Supabase migration for ChangesInterfaces feedback access flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to 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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Updates to Preview Branch (kanad-2026-07-28/interfaces-feedback-table-take-2) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
supabase/migrations/20260728035858_create_interfaces_feedback.sql
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]>
This comment was marked as resolved.
This comment was marked as resolved.
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]>
|
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. |
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]>
|
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. |
Braintrust eval report |
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]>
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
feedbackandfeedback_commentstables 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:idbigintidentitycreated_attimestamptznot null default now()feedbacktextnot null, ≤ 1000 chars — the free-form feedbackdelete_tokenuuidunique not null; authorizes deleting the rowuser_agenttextuser_idtextproject_reftextmetadatajsonbSubmission happens exclusively through a
SECURITY DEFINERfunction,submit_interfaces_feedback(...), which inserts the row and returns the server-generateddelete_tokenexactly 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 fromPUBLICand granted toanononly (both statements matter: local and hosted databases have different default function ACLs).Deletion is a hard
DELETEauthorized by presenting the token in anx-feedback-tokenrequest header. RLS policies compare the row'sdelete_tokenagainst 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 touuidand compared against the untransformed column, so lookups use the unique index ondelete_tokeneven for header-only reads; a malformed token header is rejected with a400(22P02), consistent with what a malformed URL filter value already returns.Context gate (defense-in-depth): rows submitted with a
project_refand/oruser_idadditionally require the matchingx-feedback-project-ref/x-feedback-user-idheaders — on both reads and deletes — so a leaked bare token can neither read the submission text back nor remove the row. ANULLcolumn 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_idare 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: */1vs*/0). No other columns are readable by any API role;delete_tokenneeds 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 forauthenticated.Additional context
Linear tickets: CLI-1946, CLI-1999
The client-side flows (
supabase feedback add/feedback deletein 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