adrianhajdin / podcastr

https://podcastr-23zf.vercel.app
687 stars 130 forks source link

Webhook error creating new user by e-mail #9

Open bahiensed opened 4 months ago

bahiensed commented 4 months ago

Creating users through social connections (Google, Github, etc) works.

When we create a user by e-mail, it's created in Clerk, but the Webhook fails, and therefore no new user is created in the users table on Convex.

I tried with the following http.ts action codes:

  switch (event.type) {
    case "user.created":
      await ctx.runMutation(internal.users.createUser, {
        clerkId: event.data.id,
        email: event.data.email_addresses[0].email_address,
        imageUrl: event.data.image_url,
        name: event.data.first_name as string,

        //and also:
        //name: event.data.first_name!,
        //as told in the video

      });
      break;

The error messages are:

HTTP Response: 500

"code":string"[Request ID: a0bd621c40f2252b] Server Error: Uncaught Error: ArgumentValidationError: Value does not match validator. Path: .name Value: null Validator: v.string() "

"trace":string"Uncaught Error: ArgumentValidationError: Value does not match validator. Path: .name Value: null Validator: v.string() at async <anonymous> (../convex/http.ts:18:55) at async invokeFunction (../../node_modules/convex/src/server/impl/registration_impl.ts:81:11) at async invokeHttpAction (../../node_modules/convex/src/server/impl/registration_impl.ts:424:0) at async HttpRouter.runRequest (../../node_modules/convex/src/server/router.ts:322:16) "

As by e-mail no primary_name is set, the value is null, and that's why the validator is complaining. Did anybody else notice this problem?

mirza7175 commented 2 months ago

if i create a user through Gmail , it is not storing the new user into Convex users table. Help me out with this.

image

divya-jeevanantham commented 2 months ago

To resolve this Login issue with Email, in Clerk - enable the "Personal Information" section, under the category - Email, Phone, and Username, on the Configure page of the project.

This enables the First name and Last name fields during signup, however those fields are Optional. As long as the First Name is filled in, the webhook error no longer occurs and the user is also created in the Convex. However still there are chances that some do not feed in those data which could lead back to the issue.