Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading Error Message: "Database error finding user" during signup link generation #1944

Open
KrunchMuffin opened this issue Feb 17, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@KrunchMuffin
Copy link

Issue Description

When generating a signup link using auth.admin.generateLink({ type: "signup" }), a database error results in a misleading message: "Database error finding user". This error message implies a problem with user lookup when the actual issue could be database configuration or connectivity.

In our case, the actual issue was a schema configuration problem with a Foreign Data Wrapper, but the error message led us to spend hours debugging user authentication flows instead.

Steps to Reproduce

  1. Have any database configuration issue (in our case, incorrect schema reference)
  2. Call generateLink with type "signup":
const { data: signupLink, error: signupLinkError } = await supabase.auth.admin.generateLink({
  type: "signup",
  email: "[email protected]",
  password: "randompassword",
  options: {
    redirectTo: "http://localhost:3000/complete-signup"
  }
});
  1. Receive error:
{
  __isAuthError: true,
  status: 500,
  code: 'unexpected_failure',
  message: 'Database error finding user'
}

Expected Behavior

Since this is a signup flow, the error message should:

  1. Not imply we're looking for an existing user
  2. Be more specific about the database error
  3. Potentially include the actual database error (safely) in development mode

Actual Behavior

The error message suggests a problem with user lookup, which is misleading since:

  1. This is a signup flow - we don't expect to find the user
  2. The actual database error is obscured
  3. The message leads developers to debug auth flows instead of database configuration

Suggested Improvements

  1. More descriptive error message: "Database error during signup link generation"
  2. In development, include the actual database error (sanitized if needed)
  3. Consider adding a debug mode that provides more detailed error information

Environment

  • Supabase Auth version: (latest)
  • Running in: Docker/local development
  • Database: Postgres with Foreign Data Wrapper

Additional Context

The code in GoTrue shows that user lookup is part of the flow to handle different types of links, but the error messaging doesn't reflect this implementation detail, leading to confusion during debugging.

@KrunchMuffin KrunchMuffin added the bug Something isn't working label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant