before_user_created Auth Hook Returns "Invalid payload sent to hook" Error When Rejecting User Creation
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- go, javascript
- Domain
- api, authentication
Research direction
Start by reproducing the before_user_created hook with the documented HTTP 400 JSON response and compare it with the working HTTP 200 path. Trace the auth hook response handling to find where the rejection payload becomes "Invalid payload sent to hook"; done means rejected signups return the custom error message without the unexpected_failure response.
Written by the indexing model from the issue text.
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
The before_user_created auth hook returns an "Invalid payload sent to hook" error when attempting to reject user account creation with a properly formatted HTTP 400 response. Instead of processing the rejection with the custom error message, Supabase returns an unexpected failure error.
To Reproduce
Steps to reproduce the behavior:
- Set up a
before_user_createdauth hook in your Supabase project dashboard - Configure it to point to a custom API endpoint (e.g., using ngrok for local development)
- Create an endpoint that conditionally rejects signups with this response:
return response .status(400) .set('Content-Type', 'application/json') .json({ error: { message: 'Signups from this email domain are not allowed.', http_code: 400, }, }); - Attempt to create a user account that should trigger the rejection logic
- Observe the error response from Supabase
Expected behavior
When the auth hook returns HTTP 400 with the proper error payload format, Supabase should:
- Prevent the account creation
- Return the custom error message specified in the hook response
- Handle the rejection gracefully without throwing an "Invalid payload" error
Screenshots
Error response received:
{
"code": "unexpected_failure",
"message": "Invalid payload sent to hook"
}
System information
- OS: [Various - issue occurs on server side]
- Browser: N/A (affects API calls)
- Version of supabase-js: NA
- Version of Node.js: NA
Additional context
- The API endpoint is successfully receiving requests from Supabase (confirmed via server logs)
- The API responds with the exact JSON format as documented
- When returning HTTP 200 with an empty body, account creation proceeds without issues
- This suggests the hook connectivity is working, but error handling for HTTP 400 responses is broken
- The same issue has been reported by other users (@Entropei)
- Hook URL is accessible and properly configured in the Supabase dashboard
The problem specifically occurs when trying to reject user creation - the success path works fine, but the rejection path fails with an unhelpful error message that doesn't match the documentation.
- Dominant language
- Go
- Stars
- 2.6k
- Forks
- 764
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 39
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supabase/auth
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100