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

supabase.auth.admin.generateLink regression #22562

Closed
SebasScript opened this issue Apr 8, 2024 · 4 comments
Closed

supabase.auth.admin.generateLink regression #22562

SebasScript opened this issue Apr 8, 2024 · 4 comments
Labels
auth All thing Supabase Auth related bug Something isn't working needs-analysis Issue status is unknown and/or not possible to triage with the current info

Comments

@SebasScript
Copy link

SebasScript commented Apr 8, 2024

  • [x ] I confirm this is a bug with Supabase, not with my own application.
  • [x ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

there is a related issue but the encountered error seems to be different
magiclink auth.admin.generateLink occasionally fails to create a user when it does not exist
#22521

Describe the bug

A clear and concise description of what the bug is.

const inviteOptions = {
    redirectTo: `${deployUrl}/auth/callback?next=onboarding`,
    data: userMetaData,
  };

 const { data, error } = await supabaseAdmin.auth.admin.generateLink({
      type: "invite",
      email,
      options: inviteOptions,
    });

running this in a cloud function used to create an invite link that i could send to a user via email or whats app to create a new user in supabse. After updating my local development environment to the following:

        SERVICE IMAGE      │        LOCAL         │   LINKED
  ─────────────────────────┼──────────────────────┼─────────────
    supabase/postgres      │ 15.1.0.137           │ 15.1.0.137
    supabase/gotrue        │ v2.145.0             │ v2.145.0
    postgrest/postgrest    │ v11.2.2              │ v11.2.2
    supabase/realtime      │ v2.27.5              │ -
    supabase/storage-api   │ v0.48.4              │ v0.48.4
    supabase/edge-runtime  │ v1.41.3              │ -
    supabase/studio        │ 20240326-5e5586d     │ -
    supabase/postgres-meta │ v0.80.0              │ -
    supabase/logflare      │ 1.4.0                │ -
    bitnami/pgbouncer      │ 1.20.1-debian-11-r39 │ -
    darthsim/imgproxy      │ v3.8.0               │ -

this is not working anymore. the generateLink call throws this error

AuthApiError: User with this email not found
    at we (https://esm.sh/v135/@supabase/auth-js@2.63.0/esnext/auth-js.mjs:2:6550)
    at eventLoopTick (ext:core/01_core.js:64:7)
    at async je (https://esm.sh/v135/@supabase/auth-js@2.63.0/esnext/auth-js.mjs:2:7425)
    at async h (https://esm.sh/v135/@supabase/auth-js@2.63.0/esnext/auth-js.mjs:2:7110)
    at async S.generateLink (https://esm.sh/v135/@supabase/auth-js@2.63.0/esnext/auth-js.mjs:2:9732)
    at async file:///home/deno/functions/invite-user/index.ts:56:29
    at async dispatch (https://deno.land/x/oak@v12.6.0/middleware.ts:28:7)
    at async dispatch (https://deno.land/x/oak@v12.6.0/middleware.ts:28:7)
    at async dispatch (https://deno.land/x/oak@v12.6.0/middleware.ts:28:7)
    at async errorHandling (file:///home/deno/functions/_shared/middleware.ts:89:5) {
  __isAuthError: true,
  name: "AuthApiError",
  status: 404,
  code: "user_not_found"

The api call should create a new user, but its somehow checking if the user already exists, which it shouldn't (and also didn't do before).
If changing the type to 'magiclink' the call works and a new user is generated as expected, which should be the same behaviour for 'invite'.

To Reproduce

create a cloud function and use the service key to create the supabase client, than call the create link function

export const supabaseAdmin = createClient<Database>(
  Deno.env.get("SUPABASE_URL") ?? "",
  Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? "",
  {
    auth: {
      persistSession: false,
    },
  }
);

 const { data, error } = await supabaseAdmin.auth.admin.generateLink({
      type: "invite",
      email,
      options: {
            redirectTo: `${deployUrl}/auth/callback?next=onboarding`,
            data: {firstName: 'example name'}
         },
    });

Expected behavior

a new user is created when calling generateLink as in previous versions of supabase.

System information

  • OS: windows 11, running supabase in local dev mode with docker
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: 2.42.0
  • Version of Node.js: 18.18.2
@SebasScript SebasScript added the bug Something isn't working label Apr 8, 2024
@encima encima added auth All thing Supabase Auth related needs-analysis Issue status is unknown and/or not possible to triage with the current info labels Apr 8, 2024
@iamchubko
Copy link

iamchubko commented Apr 10, 2024

I am experiencing the same problem in production which started around the same time. But I was not able to reproduce it locally

@JasonColeyNZ
Copy link

JasonColeyNZ commented Apr 17, 2024

I am also experiencing this issue, just started trying to use this feature in my app and it does not work. Doesn't work in local or production.

I just updated to 2.42.4 and restarted my docker for local dev and still have the issue..

The error returned is AuthApiError: User not allowed

It was a valid email address entered.

Same error using 'invite' or 'magiclink'

Using OSX, Chrome.

@JasonColeyNZ
Copy link

JasonColeyNZ commented Apr 17, 2024

OK, it appears this was my fault, I have it working, I didn't use the service_role_key in my SB client, my bad.

@SebasScript
Copy link
Author

I updated my local environment and the issue has been resolved, so closing this.

latest versions that are working again

      SERVICE IMAGE      │        LOCAL         │   LINKED
 ─────────────────────────┼──────────────────────┼─────────────
   supabase/postgres      │ 15.1.0.137           │ 15.1.0.137
   supabase/gotrue        │ v2.148.0             │ v2.148.0
   postgrest/postgrest    │ v11.2.2              │ v11.2.2
   supabase/realtime      │ v2.28.23             │ -
   supabase/storage-api   │ v1.0.10              │ v1.0.10
   supabase/edge-runtime  │ v1.43.2              │ -
   supabase/studio        │ 20240408-6bf3b81     │ -
   supabase/postgres-meta │ v0.80.0              │ -
   supabase/logflare      │ 1.4.0                │ -
   bitnami/pgbouncer      │ 1.20.1-debian-11-r39 │ -
   darthsim/imgproxy      │ v3.8.0               │ -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth All thing Supabase Auth related bug Something isn't working needs-analysis Issue status is unknown and/or not possible to triage with the current info
Projects
None yet
Development

No branches or pull requests

4 participants