Error when insert in table "profiles" with edge-function and SERVICE_ROLE_KEY

I'm confused today.
I have an edge function that inserts into a table with RLS enabled.

I thought I read in the documentation that if I create a client with the SERVICE_ROLE_KEY key, RLS are ignored/overridden.
This doesn't seem to be the case, given my error:

"{\n code: "42501",\n details: null,\n hint: null,\n message: 'new row violates row-level security policy for table "profiles"'\n} {"code":"42501","details":null,"hint":null,"message":"new row violates row-level security policy for table \"profiles\""}\n"

Do you have any leads on this? I've been stuck on this for several days. My edge function:
const supabase = createClient(
  Deno.env.get("SUPABASE_URL")!,
  Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!, // Admin key
)

Deno.serve(async (req) => {

    .... Previous code without bug

    const {data: newProfile, error: errorProfile} = await supabase.from('profiles').insert({
         id: ID_AUTH,
         email: newUser.email,
         first_name: newUser.first_name,
         last_name: newUser.last_name,
         photo_url: `https://ui-avatars.com/api/?size=128&background=random&name=${newUser.first_name}+${newUser.last_name}`,
  })
  if(errorProfile){
    // Si erreur pendant la création du profil on supprime également l'authentification
    console.log(errorProfile, JSON.stringify(errorProfile))
    await supabase.auth.admin.deleteUser(ID_AUTH)
    return new Response('Error creating profile', {status: 400, headers: corsHeaders})
  }

})

Thanks for help
Was this page helpful?