I am using Supabase's RLS to control which users can delete certain records in the database. The records are associated with files in a bucket that will get deleted too. I expect that if the Supabase delete request fails (i.e. because the RLS policy is violated), I will get an error, and skip the file deletion too... but it turns out that when a request violates RLS, it just returns a 200 Success code and makes no changes to the DB. But then my script has no exception to throw and the files get deleted anyway. Is there any way to get an error when the query fails so that I can skip deleting my files?
// Delete the file entry from the database
const { error: deleteError } = await supabase
.from('files')
.delete()
.eq('id', fileId);
if (deleteError) throw deleteError;
console.log("Errs", deleterror);
// Delete the object from R2
await context.env.MY_BUCKET.delete(fileData.r2_object_name);