#debugging auth

90 messages · Page 1 of 1 (latest)

glossy fractal
serene rain
#

You are passing an empty string to your mutation when a storage ID is expected. I would advice to make audioStorageId optional or nullable if it's not always needed in your mutation.

glossy fractal
#

I have made it optional and the error persisted

ashen swan
#

can you share the left side of the screen when you get the error? It sounds like you're still passing an empty string when you should avoid passing the argument entirely

glossy fractal
#

This is the app's endpoint

#

The crux of this problem is authentication . I have also followed the docs and tried all possibilities but nothing seems to work yet. So that string will continue to be empty until I have been able to get the webhook running and there has been an handshake between clerk and convex

#

So the user is now auth'd successfully in clerk but as long as the convex DB is not connected to clerk then there is no user recognised in convex.

#

So, my question: Is there any other way to connect Convex with Clerk outside the available docs because I have followed those to the letter? Thanks

#

convex ENV

glossy fractal
serene rain
#

I have not used Clerk, can you see some error message for why a webhook fails in clerk? You can also check the log page in Convex and see if there's any error from the Clerk webhook.

ashen swan
#

I mean what is to the left of the error message. I imagine it's something like

{
  audioStorageId: "",
}

But i think it should be

{
}
glossy fractal
#

It's a common error in my community so I belive it is something between clerk and convex that needs sorting

ashen swan
#

thanks. The error should go away or change if you remove the 3rd line which is audioStorageId: ""

glossy fractal
#

But like I said, this will be empty until the convex and clerk are on the same page wrt authentication. ''create podcast '' is a protected route

ashen swan
#

Can you show the source code for the webhook, especially the call-site that calls createPodcast

#

I'm focusing on the createPodcast error since that was your first question, but maybe we should focus on the webhook failures (which i can see in the clerk screenshot). As @serene rain described, do you see the webhook attempts in convex logs?

glossy fractal
#

convex logs

#

as for the 'create podcast error' it will fix itself once we get convex and clerk hooked

ashen swan
#

I don't see any webhook calls in there. Can you filter logs to the webhook calls or reissue the webhook requests from the clerk ui?

#

I would also be curious to see if clerk has more information about the failures. Knowing if it's a 404 vs 500 status code would be useful

glossy fractal
#

Clerk error is 404

ashen swan
#

Can you check the url and the http.ts / http.js file? I would also try curling the endpoint directly to see if it's a 404

#

cool. Scroll down a little?

#

That looks suspiciously like the path "/clerk" which is not the path clerk is hitting

#

now does it work?

glossy fractal
#

It doen't

#

It doesn't

ashen swan
#

did you re-issue the webhook requests from clerk after fixing the path?

glossy fractal
#

yes

ashen swan
#

the next thing to check is the url. where did you get the url that clerk is hitting?

ashen swan
#

cool that looks right. next things to try:
make sure npx convex dev is running
curl the endpoint directly and see if you get a 404

glossy fractal
#

change cloud to site . It is running and it returns 404 directly

ashen swan
#

thanks for checking. can you verify in #verify so i can take a look at the deployment on our side

ashen swan
#

curl is returning the error message No matching routes found which indicates to me that either npx convex dev isn't running or the file wasn't saved after /clerk was changed to /clerk-users-webhook

glossy fractal
#

I'm on auto-safe and npx convex dev is running

ashen swan
ashen swan
#

aha it is working. i just forgot how to use curl

#
curl -X POST -i <url here>
#

can you describe how you re-issued the clerk webhooks?

glossy fractal
ashen swan
#

and then did you log in again to create new users?

#

i don't think clerk re-issues webhook requests when you make a new webhook

#

you can try the "replay missing messages" button

glossy fractal
#

remember the secrets change so you have to update that

ashen swan
#

yep personally i wouldn't delete and recreate the webhook; i would use the existing webhook and click "recover failed messages" and "replay missing messages"

glossy fractal
#

Front end check, clerk, perfect, DB meh

glossy fractal
#

user not found

ashen swan
#

are you getting a response from curl like i did?

#

you should see error messages in the convex logs now. i've been hitting your endpoint and receiving Uncaught WebhookVerificationError: Missing required headers

glossy fractal
ashen swan
#

cool so the web is hooking. do you see any successful requests from clerk?

glossy fractal
#

clerk works well by itself

ashen swan
#

can you screenshot the logs page of the clerk webhook

glossy fractal
ashen swan
#

sorry i mean the Endpoints -> Message Attempts view in clerk. so we can see the status

#

and if the status is "Failed" click on the attempt, scroll down, and check the response code

#

and the HTTP RESPONSE CODE and RESPONSE fields?

#

cool that's an error message (and it should also appear in convex logs), can you take it from here?

glossy fractal
ashen swan
#

do you see the error message? it looks pretty actionable to me

ashen swan
#

the error message indicates that event.data.first_name is null, so you should account for it being null in the argument validation of createUser

glossy fractal
ashen swan
#

the error message doesn't mention schema, it mentions ArgumentValidationError

#

i recommend removing the exclamation point from event.data.first_name! as it prevents typescript from telling you about this bug

glossy fractal
#

I hope you know this is not an isolated error. It is very common in my community.

ashen swan
#

what do you mean by your community

#

it sounds like until this morning clerk was hitting /clerk-users-webhook while convex was listening on /clerk. once you fixed that, you started hitting an issue because your convex function expects all users to have a first name while some users in clerk have first_name: null

ashen swan
#

okay well i'm not sure how to help. i understand it's frustrating when everything seems to be failing, but working through the issues one by one should eventually get there. the error message is describing a field that is being passed as null while argument validation requires it to be a string.

#

concretely, i imagine the code looks like

const createUser = internalMutation({
  args: { ..., name: v.string() },
  handler: async (ctx, args) => {...}
});

and if you change name: v.string() to name: v.union(v.string(), v.null()) you should get past this error

#

if you can link to the docs that are leading you to hit errors like this, we would appreciate it. we're always looking to improve documentation.

glossy fractal
glossy fractal
glossy fractal
undone plaza
#

Locking this post, as things feel as they're getting less constructive. sorry we weren't able to be more helpful. Please escalate this to a pro support ticket if you require more attention from our team.