Fixing AI-built apps
Your app shows the data to you, but your users see nothing. Here's the Supabase setting behind it.
By Alexa · 28 November 2026 · 8 minute read
In the builder, everything works. You add a booking, it shows up in the list. Then a real user logs in and the list is empty. Or saving fails with "new row violates row-level security policy". Or the browser console says "permission denied for table". If your app was built with Lovable, Bolt or another AI builder on Supabase, all three usually point to the same thing: the rules that decide who can see and change each row.
What row level security does
Supabase lets your app talk to the database straight from the browser. To keep that safe, each table has rules called row level security (RLS) policies. They answer questions like "which rows can this user read?" and "can they add a row, and what has to be true about it?".
The important detail: once RLS is switched on for a table, Supabase lets nothing through to your app until you add policies. In Supabase's words, no data is accessible through the API with the public key until you create policies.
Every request your app makes runs as one of two roles: anon when nobody is logged in, and authenticated when someone is. A policy says which role it's for and which rows it allows.
Why it works for you and not for your users
You, in the Supabase dashboardTable editorAdmin accessEvery row, rules ignored
A user, in your appYour appLogged-in userOnly rows a policy allows
The dashboard isn't logged in as one of your users, so seeing the rows there doesn't mean your app can.
Find your error
- The list is empty, with no error. RLS is on and no policy lets this user read these rows, or the request isn't logged in at all. Supabase returns an empty list, not an error, which makes it easy to miss. See fix 1.
- "new row violates row-level security policy" when saving. There's no policy that lets this user add the row, or the row doesn't match it, for example the
user_id column isn't filled in. See fix 2.
- The same error when uploading a file. Storage has its own policies. See fix 3.
- "permission denied for table" (code 42501). The role has no access to the table at all, before any policy is even checked. See fix 4.
Fix 1: the list is empty
Supabase's own troubleshooting guide says an empty result usually means RLS is on with no policy, or the user doesn't meet the policy. Check in this order:
- Is there a read policy? In Supabase, open Authentication → Policies and find the table. No policy for
SELECT means nobody can read it through your app.
- Is the user actually logged in when the request runs? If the page loads before the login finishes, the request goes out as
anon, and a policy for logged-in users doesn't match.
- Do the rows belong to this user? A typical policy only shows rows where
user_id is the logged-in user. Rows you made while testing belong to you, not to them.
A policy that lets each logged-in user read their own rows looks like this (from Supabase's docs, with your table and column names):
create policy "Users can view their own bookings"
on bookings for select
to authenticated
using ( (select auth.uid()) = user_id );
If everyone should see the rows, like a public menu or a list of services, the policy can allow it for anon too. Only do that for data that's meant to be public.
Fix 2: "new row violates row-level security policy"
This one comes up when adding or changing a row. Either there's no policy for INSERT (or UPDATE), or the new row doesn't pass its check. The usual reason in AI-built apps: the app doesn't send user_id, so the row doesn't belong to the person saving it.
create policy "Users can add their own bookings"
on bookings for insert
to authenticated
with check ( (select auth.uid()) = user_id );
The with check part makes sure nobody can create a row that belongs to someone else. To stop the app from forgetting user_id, set the column's default to auth.uid(), so Supabase fills it in.
If the error appears right after saving, check whether the app reads the row back (many do). Then it also needs a read policy, from fix 1.
Fix 3: uploads fail with 403
File uploads have their own policies, on Supabase Storage. Two common causes:
- No upload policy on the bucket. Add an insert policy for logged-in users, usually limited to their own folder.
- The upload is set to overwrite. Supabase explains that with
upsert: true, the upload also reads the file's details back, so it needs a read policy too. Either add one that matches the upload policy, or turn overwrite off.
Fix 4: "permission denied for table"
This is a step before RLS: the role your app uses (anon or authenticated) has no permission on the table at all. It often happens with tables in a schema other than public, or when someone removed the permissions while "making it secure". Give back only what the app needs, and keep RLS on to decide which rows:
grant select, insert, update on bookings to authenticated;
Rather not touch the policies yourself? Wrong policies are easy to make and hard to spot, and some open your data to everyone. I can fix your AI-built app's data and logins for a fixed price, and you pay only once it works.
Two shortcuts that make it worse
- Turning RLS off. Your data shows again, but now anyone with your app's public key can read and change every row, including other users' data. Use it only for a minute, to test whether RLS is the cause, then switch it back on.
- Putting the secret key in the app. The secret (service role) key ignores every policy. Supabase says never to use it in the browser. If an AI builder suggested it, take it out and use policies instead. It's also cause 7 in why apps break after going live.
One more trap: database views ignore RLS by default. If your app reads from a view, Supabase recommends creating it with security_invoker = true so the table's policies apply.
Questions people ask
Why does Supabase return an empty array when the rows exist?
Usually because row level security is on and no policy lets this user read those rows, or the request isn't logged in. Supabase returns an empty list instead of an error. Add a select policy for the right role.
Why does my data show in the Supabase dashboard but not in my app?
The dashboard doesn't use your app's login, so it isn't limited by your policies. Your app only sees the rows a policy allows for the logged-in user.
Is it safe to turn off row level security?
No. Without it, anyone with your app's public key can read and change every row. Keep it on and add policies for what each user should see.
What does "new row violates row-level security policy" mean?
The user tried to add or change a row that no policy allows, often because the row's user_id isn't theirs or isn't filled in. Add an insert policy and set user_id to fill in automatically.
Can you fix it for me?
Yes. I check every table's policies, fix what's broken and test it as a real user, for a fixed price, and you pay only once it works.
Want it done for you?
Fixing the policies of a small app usually fits in one fix, from $170, and you pay only once your users see their data. See how it works.
Sources
- Row Level Security, Supabase docs (no access until policies exist, the anon and authenticated roles, example policies, secret keys, views).
- Why is my select returning an empty data array?, Supabase troubleshooting.
- Storage error 403 on upload, Supabase troubleshooting.