SupabaseS
Supabase2mo ago
tele

Supabase table editor internal errors after AI assistant security invoker revert on a view

I made some changes with the supabase AI assistant, and tl;dr is that my users table is working but in the table editor, completely malfunctional.

I have a users table, with a public view for the non-private detail that needs to be visible to anon users.
I created this view with the following SQL provided below:

This was my first time using a view instead of just tables, and after running this, there was a button which prompted me to enable the security invoker, an autofix. I clicked this, which broke most of my code, so I asked the supabase AI assistant to revert it, which it 'succesfully did'. However, this makes the users table page inoperable.
-- This view shows EVERY ad separately (one row per ad)
CREATE OR REPLACE VIEW public_tutor_ads AS
SELECT 
  -- Ad information
  a.ad_id,
  a.hourly_rate,
  a.description,
  a.title,
  a.first_30_min_free,
  a.search_tags,
  a.academic_levels,
  a.created_at as ad_created_at,
  
  -- Tutor information (excluding sensitive fields)
  t.tutor_id,
  t.user_id,
  t.total_class_hours_given,
  t.average_review_score,
  t.total_review_count,
  t.about_me,
  t.video_url,
  t.diploma_url,
  t.id_verified,
  t.diploma_verified,
  t.created_at as tutor_joined_date,
  
  -- Safe user fields (NO email, NO sensitive PII)
  u.first_name,
  u.last_name,
  u.gender,
  u.languages,
  u.avatar_image_url,
  u.country,
  u.created_at as user_created_at
  
FROM ads a
INNER JOIN tutors t ON a.created_by_tutor_id = t.tutor_id
INNER JOIN users u ON t.user_id = u.user_id
WHERE a.is_enabled = true;

-- 3. Grant public access to the view ONLY
GRANT SELECT ON public_tutor_ads TO anon;
GRANT SELECT ON public_tutor_ads TO authenticated;

-- 4. Add helpful comment
COMMENT ON VIEW public_tutor_ads IS 
  'Public view of tutor ads with only safe, non-sensitive information. Each row represents one ad. Excludes email, r2_id_key, and total_cash_earned.';

-- 5. Verify the view works
-- Run this to test:
SELECT * FROM public_tutor_ads LIMIT 5;
Was this page helpful?