Repository navigation
docs: note SELECT RLS needed for INSERT RETURNING via Data API - #48308
rohanpatel2002 wants to merge 1 commit into
Conversation
Clarify why INSERT policies can pass in SQL but fail over PostgREST when the client requests the inserted row back. Related to supabase#48302
|
Thanks for contributing to Supabase! ❤️ Our team will review your PR. A few tips for a smoother review process:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@rohanpatel2002 is attempting to deploy a commit to the Supabase Team on Vercel. A member of the Team first needs to authorize it. |
|
Caution Review failedFailed to post review comments. We encountered an issue with GitHub. Use ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
|
| Layer / File(s) | Summary |
|---|---|
Document row-returning INSERT requirements apps/docs/content/guides/database/postgres/row-level-security.mdx |
Adds a caution explaining INSERT ... RETURNING * behavior, when an INSERT-only policy is sufficient, and how to add a matching SELECT policy. |
Estimated code review effort: 1 (Trivial) | ~3 minutes
Suggested reviewers: alaister
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | The description omits the template's required YES/NO, change type, current behavior, new behavior, and additional context sections. | Rewrite the PR description to follow the template and add each required section, including the CONTRIBUTING acknowledgement, change type, current/new behavior, and context. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly matches the doc update about needing SELECT RLS for INSERT RETURNING via the Data API. |
| 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. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
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 @coderabbitai help to get the list of available commands.
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 `@apps/docs/content/guides/database/postgres/row-level-security.mdx`:
- Around line 229-237: Update the SQL Editor example near the profiles
INSERT/RETURNING explanation so its execution context matches the
`authenticated` role targeted by the insert policy. Replace the `set role anon`
context or revise the example policy accordingly, ensuring the plain INSERT can
actually pass the INSERT policy before demonstrating the separate
`RETURNING`/SELECT requirement.
🪄 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: 37a05002-47c1-4ebe-a8e0-d1c60eda6c40
📒 Files selected for processing (1)
apps/docs/content/guides/database/postgres/row-level-security.mdx
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Docs update
What is the current behavior?
The RLS guide warns that
UPDATEneeds a matchingSELECTpolicy, but the INSERT section does not mention that Data API inserts which return the row (Prefer: return=representation/ supabase-js.insert(...).select()) runINSERT … RETURNING *and also needSELECTRLS.That leads to reports like #48302 (same pattern as #43528 / #47917): INSERT policy + GRANT look correct,
SET ROLE anon; INSERTworks in the SQL Editor, but REST still returns42501.What is the new behavior?
Under INSERT policies, the guide now cautions that:
RETURNING.select(), usePrefer: returninimal, or add a SELECT policy (example included)Additional context
No product code changes. Aligns INSERT docs with the existing UPDATE SELECT warning and with Storage’s INSERT+RETURNING troubleshooting note.