Skip to content

feat(creator-packs): add RLS policy and integrate Supabase client#51

Merged
creatorcluster merged 2 commits into
creatorcluster:mainfrom
Coder-soft:main
Apr 20, 2026
Merged

feat(creator-packs): add RLS policy and integrate Supabase client#51
creatorcluster merged 2 commits into
creatorcluster:mainfrom
Coder-soft:main

Conversation

@Coder-soft
Copy link
Copy Markdown

@Coder-soft Coder-soft commented Apr 20, 2026

Changes

  • fixed auth
  • fixed creatorpacks
  • updtes rls policy
  • fix supabase client
  • fix posthog (postponed)
  • updated vars

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Creator Packs section with dedicated navigation and routing.
  • Security

    • Implemented Row Level Security policies to ensure only approved creator packs are publicly accessible and users can only manage their own submissions.
  • Improvements

    • Enhanced error logging and diagnostics for better debugging capabilities.
    • Updated Supabase integration configuration.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

@Coder-soft is attempting to deploy a commit to the yamura3's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@Coder-soft has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 49 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 49 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d82c6a5-a6d9-4de3-bf41-73555194f856

📥 Commits

Reviewing files that changed from the base of the PR and between 6c819a3 and b4a9211.

📒 Files selected for processing (3)
  • .gitignore
  • src/hooks/useCreatorPacks.ts
  • supabase/migrations/20260420000000_creator_packs_rls_policy.sql
📝 Walkthrough

Walkthrough

This PR introduces MCP integration configuration, updates the Hero component to feature creator packs navigation, enhances logging in the pack fetching hook, modifies Supabase client authentication setup, and establishes row-level security policies for the creator_packs table.

Changes

Cohort / File(s) Summary
Configuration & Infrastructure
opencode.json, src/integrations/supabase/client.ts
Added new MCP integration configuration with Supabase endpoint and changed Supabase client auth from VITE_SUPABASE_ANON_KEY to VITE_SUPABASE_PUBLISHABLE_KEY.
UI Navigation
src/components/Hero.tsx
Updated Hero component CTAs: primary button now routes to /resources?tab=creator-packs with "Creator Packs" label and IconPackage icon; secondary button routes to /resources?tab=music-packs with "Music Packs" label and restored IconMusic icon.
Logging Enhancement
src/hooks/useCreatorPacks.ts
Added structured logging for Supabase query errors (message/details/hint/code), success path logs for fetched packs, and raw error logging in catch block with additional object-level details when applicable.
Database Security
supabase/migrations/20260420000000_creator_packs_rls_policy.sql
Created two RLS policies on creator_packs table: a public read policy for approved status, and a user-scoped policy restricting insert/update/delete to rows matching auth.uid() = user_id.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A package of joy, now publicly told,
Creator packs shine, a sight to behold!
With security walls and tabs, clean and true,
The MCP connection brings features anew!

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately captures the main changes: adding RLS policy and integrating the Supabase client, which are core themes across multiple files in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

❤️ Share

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 20, 2026

Greptile Summary

This PR adds RLS policies for the creator_packs table, renames the Supabase anon-key env variable, enhances error logging in useCreatorPacks, and updates the Hero CTA buttons to surface creator packs. Two blocking issues need attention before merging:

  • Env var rename breaks existing deployments: client.ts now reads VITE_SUPABASE_PUBLISHABLE_KEY, but api/deleteAccount.js still reads VITE_SUPABASE_ANON_KEY. Any environment without the new key will silently fail all Supabase queries.
  • Missing admin RLS policy blocks pack reviews: The migration only creates a public-read and an owner-write policy. The reviewPack function updates packs by ID without an auth.uid() = user_id filter, so admin approval/rejection will be blocked by RLS — the same pattern used for resources (email-based admin policy) is missing here.

Confidence Score: 3/5

Not safe to merge — two P1 defects will break the Supabase client initialization and disable admin pack review in production.

Two active P1 bugs: the env-var rename silently kills all frontend Supabase calls in un-updated environments, and the missing admin RLS policy permanently blocks the pack review workflow for admins.

src/integrations/supabase/client.ts and supabase/migrations/20260420000000_creator_packs_rls_policy.sql require fixes before merging.

Security Review

  • Supabase project ref exposed in opencode.json: The MCP config URL embeds the project reference ID and is committed to the repository. While not a secret key, it should be gitignored to limit unnecessary exposure.
  • Overly broad FOR ALL RLS policy: The owner-management policy grants SELECT on non-approved rows to the row owner, which appears intentional (user dashboard), but the interaction with the public SELECT policy should be confirmed to avoid leaking pending/rejected pack data to unintended callers.

Important Files Changed

Filename Overview
src/integrations/supabase/client.ts Env var renamed from VITE_SUPABASE_ANON_KEY to VITE_SUPABASE_PUBLISHABLE_KEY — breaks if deployment env isn't updated; inconsistent with api/deleteAccount.js which still reads the old name.
supabase/migrations/20260420000000_creator_packs_rls_policy.sql Adds public read and owner-management RLS policies, but omits an admin/reviewer policy required by the reviewPack function, which will silently block all pack approvals/rejections.
src/hooks/useCreatorPacks.ts Enhanced error logging in fetchPacks; debug console.log left in on line 128 should be removed before merging.
src/components/Hero.tsx Hero CTA buttons updated to point to creator-packs and music-packs tabs respectively — straightforward UI routing change.
opencode.json New IDE config file committed to the repo; contains the Supabase project ref and should instead be gitignored.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Supabase Client Init] -->|reads VITE_SUPABASE_PUBLISHABLE_KEY| B{Key defined?}
    B -- Yes --> C[Client initialized ✓]
    B -- No / undefined --> D[All DB calls fail ✗]

    E[User visits site] --> F[fetchPacks]
    F --> G[(creator_packs RLS)]
    G -->|Policy: status = approved| H[Public read ✓]

    I[Authenticated user] --> J[createPack / updatePack / deletePack]
    J --> G
    G -->|Policy: auth.uid = user_id| K[Owner write ✓]

    L[Admin calls reviewPack] --> M[UPDATE by id only]
    M --> G
    G -->|No admin policy exists| N[Blocked by RLS ✗]
Loading

Reviews (1): Last reviewed commit: "feat(creator-packs): add RLS policy and ..." | Re-trigger Greptile


const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL as string;
const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_ANON_KEY as string;
const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY as string;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Breaking env-var rename diverges from api/deleteAccount.js

client.ts now reads VITE_SUPABASE_PUBLISHABLE_KEY, but api/deleteAccount.js (line 36) still reads VITE_SUPABASE_ANON_KEY. Any deployment environment that has not yet added the new variable name will initialize the Supabase client with undefined as the API key, causing every database call in the frontend to silently fail. The server-side account-deletion flow also retains the old name, creating a permanent inconsistency.

Either revert the rename to keep using the standard VITE_SUPABASE_ANON_KEY, or update api/deleteAccount.js and all deployment environments atomically with this PR.

Comment on lines +11 to +14
CREATE POLICY "Users can manage their own creator packs" ON creator_packs
FOR ALL
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id); No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 No admin/reviewer policy — reviewPack will be silently blocked

The reviewPack function in useCreatorPacks.ts updates status and review_reason on packs the admin does not own (using only .eq('id', id), no user_id filter). With the new policies in place, that UPDATE will be blocked by RLS for any row where auth.uid() ≠ user_id, causing the function to return zero rows or an RLS error and leaving packs permanently stuck in pending.

A reviewer/admin policy is needed, consistent with the pattern used elsewhere in the codebase (e.g. auth.jwt() ->> 'email' = 'yamura@duck.com'):

CREATE POLICY "Admins can review creator packs" ON creator_packs
FOR UPDATE
USING (auth.jwt() ->> 'email' = 'yamura@duck.com')
WITH CHECK (auth.jwt() ->> 'email' = 'yamura@duck.com');

Comment thread src/hooks/useCreatorPacks.ts Outdated
});
throw error;
}
console.log('Fetched packs:', data);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Debug console.log left in production code

This log will print every fetched pack record to the browser console in production. It should be removed before merging.

Comment thread opencode.json
"mcp": {
"supabase": {
"type": "remote",
"url": "https://mcp.supabase.com/mcp?project_ref=bmywdrwjdqmrkafhiuwn&features=docs%2Cdatabase%2Cdebugging%2Cdevelopment%2Cfunctions%2Cbranching",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 security Developer tool config with project ref committed to repo

opencode.json is an AI-IDE config file that encodes the Supabase project reference directly in the URL. While the project ref alone is not a secret key, committing IDE-specific tooling configs to the repository creates noise and unnecessarily exposes the project identifier. This file should be added to .gitignore rather than tracked.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hooks/useCreatorPacks.ts (1)

119-138: ⚠️ Potential issue | 🟡 Minor

Debug logging is fine, but trim noise and restore user-facing error feedback.

Two small concerns in this catch/log block:

  1. console.log('Fetched packs:', data) logs every approved pack on every fetch in production — consider gating behind import.meta.env.DEV or removing before merge.
  2. The catch now logs the error twice ('Error fetching creator packs:' and 'Error details:') but — unlike sibling fetchers such as fetchUserPacks/fetchPendingPacks — no longer surfaces a toast.error(...) to the user. A silent empty list on failure is worse UX than the previous behavior.
♻️ Suggested cleanup
-            if (error) {
-                console.error('Supabase error details:', {
-                    message: error.message,
-                    details: error.details,
-                    hint: error.hint,
-                    code: error.code
-                });
-                throw error;
-            }
-            console.log('Fetched packs:', data);
+            if (error) {
+                console.error('Supabase error fetching creator packs:', {
+                    message: error.message,
+                    details: error.details,
+                    hint: error.hint,
+                    code: error.code,
+                });
+                throw error;
+            }
+            if (import.meta.env.DEV) {
+                console.debug('Fetched packs:', data?.length);
+            }
             setPacks((data as CreatorPackWithProfiles[])?.map(mapToCreatorPack) || []);
         } catch (error: unknown) {
-            console.error('Error fetching creator packs:', error);
-            if (error && typeof error === 'object' && 'message' in error) {
-                console.error('Error details:', (error as { message: unknown }).message);
-            }
+            console.error('Error fetching creator packs:', getErrorMessage(error));
+            toast.error('Failed to load creator packs.');
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useCreatorPacks.ts` around lines 119 - 138, The catch/log block in
useCreatorPacks is noisy and omits user feedback: remove or gate the noisy
console.log('Fetched packs:', data) behind import.meta.env.DEV (or delete it),
collapse duplicate error logs into a single console.error that includes the
error message, and restore user-facing feedback by calling the same
toast.error(...) pattern used in fetchUserPacks/fetchPendingPacks inside the
catch (use the error.message when available); ensure setIsLoading(false) remains
in finally and keep setPacks((data as
CreatorPackWithProfiles[])?.map(mapToCreatorPack) || []) unchanged.
🧹 Nitpick comments (2)
src/components/Hero.tsx (1)

123-154: Route changes look correct; consider aligning the "NEW" badge copy.

Both ?tab=creator-packs and ?tab=music-packs are handled by ResourcesHub.tsx (Lines 111–117 and 276–295), so the new CTAs will activate the correct tab. 👍

Minor copy nit: the NEW badge on Line 127 still reads “Music Packs On Resources Hub” while the primary CTA has been promoted to Creator Packs. If creator packs are the new headline feature, it may read more consistently as something like “Creator Packs On Resources Hub”. Non-blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Hero.tsx` around lines 123 - 154, Update the NEW badge copy to
match the promoted CTA by changing the badge text (the span that currently says
"Music Packs On Resources Hub") to reference Creator Packs instead (e.g.,
"Creator Packs On Resources Hub") so it aligns with the Link
to="/resources?tab=creator-packs" CTA in Hero.tsx; locate the badge span element
near the inline-flex container wrapping the NEW pill and update its inner text
accordingly.
opencode.json (1)

1-10: Consider whether this editor/tooling config belongs in the repo.

opencode.json is personal IDE/tooling config for the OpenCode MCP integration. The project_ref embedded in the URL isn’t secret (it’s present in the public Supabase URL), but committing editor tooling config generally causes churn and can confuse collaborators who don’t use OpenCode. Consider either:

  • Adding it to .gitignore and keeping it local, or
  • Documenting it in README.md / CONTRIBUTING.md so contributors understand its purpose.

No functional impact on the app.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@opencode.json` around lines 1 - 10, opencode.json contains personal OpenCode
MCP/editor tooling settings (the "mcp" -> "supabase" block including the
"project_ref" in the URL) which should not be committed as repo-level config;
either remove opencode.json from the repo and add it to .gitignore, or keep the
file but add a short note in README.md or CONTRIBUTING.md explaining the purpose
of the "mcp"/"supabase" entry and why contributors can ignore it so
collaborators aren’t confused by the editor-specific config.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/integrations/supabase/client.ts`:
- Line 6: The backend is still reading VITE_SUPABASE_ANON_KEY while the frontend
uses VITE_SUPABASE_PUBLISHABLE_KEY, causing a runtime mismatch; update
api/deleteAccount.js to read VITE_SUPABASE_PUBLISHABLE_KEY if you want parity,
but preferably switch the backend to use the Supabase service-role key (e.g.,
SUPABASE_SERVICE_ROLE_KEY) for privileged operations instead of any
publishable/anon key; change the environment variable reference in
api/deleteAccount.js, update any Supabase client initialization there to use the
service-role key variable (and keep VITE_SUPABASE_PUBLISHABLE_KEY only for
front-end usage), and add a note to the deployment/env setup docs or README
explaining this breaking env-var rename so contributors update their .env
accordingly.

In `@supabase/migrations/20260420000000_creator_packs_rls_policy.sql`:
- Around line 1-14: Add an "ENABLE ROW LEVEL SECURITY" statement for the
creator_packs table before the CREATE POLICY statements so the policies take
effect; modify the migration to execute ALTER TABLE creator_packs ENABLE ROW
LEVEL SECURITY (before creating "Creator packs are publicly readable if
approved" and "Users can manage their own creator packs") ensuring the RLS is
enabled defensively just like resources migration so the FOR ALL / USING
policies on creator_packs apply.

---

Outside diff comments:
In `@src/hooks/useCreatorPacks.ts`:
- Around line 119-138: The catch/log block in useCreatorPacks is noisy and omits
user feedback: remove or gate the noisy console.log('Fetched packs:', data)
behind import.meta.env.DEV (or delete it), collapse duplicate error logs into a
single console.error that includes the error message, and restore user-facing
feedback by calling the same toast.error(...) pattern used in
fetchUserPacks/fetchPendingPacks inside the catch (use the error.message when
available); ensure setIsLoading(false) remains in finally and keep
setPacks((data as CreatorPackWithProfiles[])?.map(mapToCreatorPack) || [])
unchanged.

---

Nitpick comments:
In `@opencode.json`:
- Around line 1-10: opencode.json contains personal OpenCode MCP/editor tooling
settings (the "mcp" -> "supabase" block including the "project_ref" in the URL)
which should not be committed as repo-level config; either remove opencode.json
from the repo and add it to .gitignore, or keep the file but add a short note in
README.md or CONTRIBUTING.md explaining the purpose of the "mcp"/"supabase"
entry and why contributors can ignore it so collaborators aren’t confused by the
editor-specific config.

In `@src/components/Hero.tsx`:
- Around line 123-154: Update the NEW badge copy to match the promoted CTA by
changing the badge text (the span that currently says "Music Packs On Resources
Hub") to reference Creator Packs instead (e.g., "Creator Packs On Resources
Hub") so it aligns with the Link to="/resources?tab=creator-packs" CTA in
Hero.tsx; locate the badge span element near the inline-flex container wrapping
the NEW pill and update its inner text accordingly.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eb9457aa-9aa2-4377-a5d4-02893b7a1c78

📥 Commits

Reviewing files that changed from the base of the PR and between e9825d3 and 6c819a3.

📒 Files selected for processing (5)
  • opencode.json
  • src/components/Hero.tsx
  • src/hooks/useCreatorPacks.ts
  • src/integrations/supabase/client.ts
  • supabase/migrations/20260420000000_creator_packs_rls_policy.sql


const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL as string;
const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_ANON_KEY as string;
const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY as string;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find any remaining references to the old env var name across the repo.
rg -nP '\bVITE_SUPABASE_ANON_KEY\b|\bSUPABASE_ANON_KEY\b' -C2
# Also check env example files.
fd -HI -t f '\.env' -x rg -nH 'SUPABASE' {}

Repository: creatorcluster/renderdragon.org

Length of output: 547


🏁 Script executed:

#!/bin/bash
# 1. Verify the client.ts file has the new env var name
echo "=== Checking src/integrations/supabase/client.ts ==="
head -20 src/integrations/supabase/client.ts

# 2. Find all .env* files
echo -e "\n=== All .env* files in repo ==="
fd -HI '\.env' --type f

# 3. Check content of env example files
echo -e "\n=== Checking .env example files ==="
fd -HI '\.env.*example' --type f -x cat -n {}

# 4. Find all backend handlers (common patterns)
echo -e "\n=== Checking for SUPABASE env vars in all backend/api handlers ==="
rg -l 'VITE_SUPABASE|SUPABASE_(ANON|URL|KEY)' api/ --type js --type ts 2>/dev/null | head -20

# 5. Check all references to both old and new env var names
echo -e "\n=== All references to SUPABASE env vars (new and old) ==="
rg 'VITE_SUPABASE_(PUBLISHABLE_KEY|ANON_KEY)|SUPABASE_(ANON_KEY|PUBLISHABLE_KEY)' -n

Repository: creatorcluster/renderdragon.org

Length of output: 1235


Update backend to match renamed env var — this is a breaking change.

The frontend now reads VITE_SUPABASE_PUBLISHABLE_KEY, but api/deleteAccount.js (line 36) still reads VITE_SUPABASE_ANON_KEY. This mismatch will cause the backend to fail at runtime when users deploy this change without manually coordinating their .env configuration.

Update api/deleteAccount.js line 36 to read VITE_SUPABASE_PUBLISHABLE_KEY or (preferably) switch to the Supabase service-role key on the backend instead of the publishable/anon key.

Since no .env.example file currently exists in the repo, ensure any deployment documentation or environment setup notes call out this breaking change for contributors.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/integrations/supabase/client.ts` at line 6, The backend is still reading
VITE_SUPABASE_ANON_KEY while the frontend uses VITE_SUPABASE_PUBLISHABLE_KEY,
causing a runtime mismatch; update api/deleteAccount.js to read
VITE_SUPABASE_PUBLISHABLE_KEY if you want parity, but preferably switch the
backend to use the Supabase service-role key (e.g., SUPABASE_SERVICE_ROLE_KEY)
for privileged operations instead of any publishable/anon key; change the
environment variable reference in api/deleteAccount.js, update any Supabase
client initialization there to use the service-role key variable (and keep
VITE_SUPABASE_PUBLISHABLE_KEY only for front-end usage), and add a note to the
deployment/env setup docs or README explaining this breaking env-var rename so
contributors update their .env accordingly.

Comment on lines +1 to +14
-- Drop existing policies if they exist to avoid conflicts
DROP POLICY IF EXISTS "Creator packs are publicly readable if approved" ON creator_packs;
DROP POLICY IF EXISTS "Users can manage their own creator packs" ON creator_packs;

-- Allow anyone to read approved creator packs
CREATE POLICY "Creator packs are publicly readable if approved" ON creator_packs
FOR SELECT
USING (status = 'approved');

-- Allow users to insert, update, and delete their own creator packs
CREATE POLICY "Users can manage their own creator packs" ON creator_packs
FOR ALL
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id); No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check whether an earlier migration already enables RLS on creator_packs.
rg -nP -C2 'creator_packs' --iglob 'supabase/migrations/*.sql' | rg -n -i 'row level security|enable row|rls'

Repository: creatorcluster/renderdragon.org

Length of output: 1548


🏁 Script executed:

# Find all migrations related to creator_packs to understand the sequence
ls -1 supabase/migrations/*.sql | sort

# Search for the migration that creates the creator_packs table
rg -l 'CREATE TABLE.*creator_packs' supabase/migrations/

# Search for any ENABLE ROW LEVEL SECURITY statements on creator_packs across all migrations
rg 'ALTER TABLE creator_packs.*ENABLE ROW LEVEL SECURITY' supabase/migrations/

Repository: creatorcluster/renderdragon.org

Length of output: 640


🏁 Script executed:

# Search all migrations for any mention of creator_packs
rg 'creator_packs' supabase/migrations/ -l

# Also check if there's a schema.sql or initial schema file
find supabase -name "*.sql" -type f | sort

# Get full content of migrations that mention creator_packs
rg 'creator_packs' supabase/migrations/ --no-filename -B5 -A5

Repository: creatorcluster/renderdragon.org

Length of output: 1321


🏁 Script executed:

# Check all SQL files in supabase directory
find supabase -name "*.sql" -type f

# Search in schema files for creator_packs table definition
rg 'CREATE TABLE.*creator_packs' supabase/

Repository: creatorcluster/renderdragon.org

Length of output: 640


🏁 Script executed:

# Broader search for creator_packs anywhere in the codebase
rg 'creator_packs' . --type-list

# Also search TypeScript/JavaScript files
rg 'creator_packs' . -t ts -t tsx -t js -t json

# Check if there's any Prisma schema or other ORM definitions
find . -name "*.prisma" -o -name "schema.prisma"

Repository: creatorcluster/renderdragon.org

Length of output: 492


🏁 Script executed:

# Search for creator_packs in entire repo
rg 'creator_packs' . --no-heading -n

# Also check specific directories for any table/schema definitions
rg 'creator_packs' src/ --no-heading -n 2>/dev/null || true

# Check if there's a types or schema directory
ls -la src/ 2>/dev/null | head -20

Repository: creatorcluster/renderdragon.org

Length of output: 3342


🏁 Script executed:

# Check the supabase types file to understand table definition
head -n 200 src/integrations/supabase/types.ts | tail -n 50

# Look for any schema or seed files in supabase directory
find supabase -type f -name "*.json" -o -name "*schema*" -o -name "*seed*"

# Check if there's a Supabase config or any other initialization
cat supabase/config.json 2>/dev/null || true
ls -la supabase/ | head -20

Repository: creatorcluster/renderdragon.org

Length of output: 1782


🏁 Script executed:

# Check git log to see if creator_packs table creation is in an earlier commit
git log --all --oneline --source --remotes -- supabase/migrations/ | head -20

# Check if there are any other branches or stashes
git branch -a

# Search for any mention of "creator_packs" in recent commits
git log --all -S 'creator_packs' --oneline | head -10

Repository: creatorcluster/renderdragon.org

Length of output: 161


🏁 Script executed:

# Check all SQL migration files for any ENABLE ROW LEVEL SECURITY statements
rg 'ENABLE ROW LEVEL SECURITY|FORCE ROW LEVEL SECURITY' supabase/migrations/

Repository: creatorcluster/renderdragon.org

Length of output: 206


Add ENABLE ROW LEVEL SECURITY to the creator_packs table.

CREATE POLICY statements have no effect unless RLS is enabled on the table. This migration creates policies but does not enable RLS, meaning the table remains unprotected. The resources table enables RLS in an earlier migration, but creator_packs does not. Add this defensively before the policies:

Required addition
 -- Drop existing policies if they exist to avoid conflicts
 DROP POLICY IF EXISTS "Creator packs are publicly readable if approved" ON creator_packs;
 DROP POLICY IF EXISTS "Users can manage their own creator packs" ON creator_packs;

+-- Ensure RLS is enabled
+ALTER TABLE creator_packs ENABLE ROW LEVEL SECURITY;
+
 -- Allow anyone to read approved creator packs
 CREATE POLICY "Creator packs are publicly readable if approved" ON creator_packs

The FOR ALL USING (auth.uid() = user_id) policy correctly allows users to select their own rows regardless of status—this matches the intended behavior in useCreatorPacks.ts where fetchUserPacks retrieves a user's own pending/rejected packs.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
-- Drop existing policies if they exist to avoid conflicts
DROP POLICY IF EXISTS "Creator packs are publicly readable if approved" ON creator_packs;
DROP POLICY IF EXISTS "Users can manage their own creator packs" ON creator_packs;
-- Allow anyone to read approved creator packs
CREATE POLICY "Creator packs are publicly readable if approved" ON creator_packs
FOR SELECT
USING (status = 'approved');
-- Allow users to insert, update, and delete their own creator packs
CREATE POLICY "Users can manage their own creator packs" ON creator_packs
FOR ALL
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id);
-- Drop existing policies if they exist to avoid conflicts
DROP POLICY IF EXISTS "Creator packs are publicly readable if approved" ON creator_packs;
DROP POLICY IF EXISTS "Users can manage their own creator packs" ON creator_packs;
-- Ensure RLS is enabled
ALTER TABLE creator_packs ENABLE ROW LEVEL SECURITY;
-- Allow anyone to read approved creator packs
CREATE POLICY "Creator packs are publicly readable if approved" ON creator_packs
FOR SELECT
USING (status = 'approved');
-- Allow users to insert, update, and delete their own creator packs
CREATE POLICY "Users can manage their own creator packs" ON creator_packs
FOR ALL
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@supabase/migrations/20260420000000_creator_packs_rls_policy.sql` around lines
1 - 14, Add an "ENABLE ROW LEVEL SECURITY" statement for the creator_packs table
before the CREATE POLICY statements so the policies take effect; modify the
migration to execute ALTER TABLE creator_packs ENABLE ROW LEVEL SECURITY (before
creating "Creator packs are publicly readable if approved" and "Users can manage
their own creator packs") ensuring the RLS is enabled defensively just like
resources migration so the FOR ALL / USING policies on creator_packs apply.

@creatorcluster creatorcluster merged commit 894c336 into creatorcluster:main Apr 20, 2026
1 of 2 checks passed
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.

2 participants