Skip to content

Fix signup failure caused by RLS policy violation on profiles table #97

@ManishKudtarkar

Description

@ManishKudtarkar

Hello @AnirbansarkarS i have found this issue during user registration, the application calls supabase.auth.signUp(...) and immediately attempts to insert a new row into the profiles table.
However, the profiles table is protected by Row Level Security (RLS) with the policy:

WITH CHECK (auth.uid() = id)

At the time of insertion, the newly created user session is not always fully authenticated yet. As a result, the insert request executes as an anonymous user and fails due to the RLS policy.
Current Error

new row violates row-level security policy for table "profiles"

Expected Behavior
Signup flow should complete successfully without RLS violations.

Possible fixes include:

  • Waiting until the authenticated session is fully available before inserting into profiles

  • Creating the profile server-side using:

    • Supabase service role
    • Edge Function / API route
    • Database trigger
  • Ensuring profile creation happens in an authenticated context

Additional Context
There is also a related issue where repeated sign-up retries may trigger:

Email rate limit exceeded

This appears when confirmation emails are requested too frequently after failed signup attempts.

Suggested Improvements

  • Add proper session readiness checks before profile insertion
  • Improve error handling and retry logic during signup
  • Prevent unnecessary repeated email confirmation requests

I would like to work on this issue under GSSOC '26.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions