Fix: grant service_role write access to usage-submit tables#141
Conversation
The service client (POST /api/usage/submit) writes daily_usage, device_usage, and posts, but those tables were only GRANTed to `authenticated` — service_role relied on Postgres default privileges. Newer local Supabase images enforce table GRANTs for service_role, so a freshly-booted `supabase start` stack returns 'permission denied for table device_usage', failing the real-Supabase integration test on every PR. Hosted Supabase already has these grants, so this is a no-op there. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 51 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ 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 |
Problem
The real-Supabase integration test (
__tests__/integration/usage-submit.test.ts) fails on every open PR — and on puremainwhen re-run today — with:This is environmental drift, not caused by any PR.
device_usage(anddaily_usage,posts) were onlyGRANTed toauthenticated; the server's service-role client relied on Postgres default privileges. Newer local Supabase images (pulled fresh bysupabase start) enforce table GRANTs forservice_roleinstead, so the usage-submit write path is denied.Fix
One migration granting
service_roleexplicit write access to the three tables the submit route writes. Idempotent no-op on hosted Supabase (service_role already holds these).Validation
CI on this branch runs the real-Supabase integration job — green here proves the fix. Unblocks #124, #130, #131.
🤖 Generated with Claude Code