jas0nw01
jas0nw012d ago

signIn started to error out

hi all, im using convex auth for the sign in and it started to error out the past few days. has been working like a charm in the past
Sep 21, 19:41:02.850
failure

62ms
M

auth:store
Uncaught TypeError: Must provide arg 1 `id` to `get`

Sep 21, 19:41:02.872
failure

302ms
A

auth:signIn
Uncaught Error: Uncaught TypeError: Must provide arg 1 `id` to `get`
Sep 21, 19:41:02.850
failure

62ms
M

auth:store
Uncaught TypeError: Must provide arg 1 `id` to `get`

Sep 21, 19:41:02.872
failure

302ms
A

auth:signIn
Uncaught Error: Uncaught TypeError: Must provide arg 1 `id` to `get`
any idea what's wrong?
export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [
ConvexCredentials({
authorize: async (credentials, ctx) => {
// create user mutation

return {
userId
}
}
})
]
})
export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [
ConvexCredentials({
authorize: async (credentials, ctx) => {
// create user mutation

return {
userId
}
}
})
]
})
4 Replies
Convex Bot
Convex Bot2d ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhartthis hour
Can you share your full auth config
jas0nw01
jas0nw01OP22h ago
thanks, erquhart!
export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [
ConvexCredentials({
authorize: async (credentials, ctx) => {
const claims = await privy.verifyAuthToken(credentials.token as string)
const privyId = credentials.privyId
if (claims.userId !== privyId) {
throw new Error("Privy user ID mismatch")
}

const address = credentials.address || ""

const email = credentials.email
if (!email) {
throw new Error("No email found in credentials")
}

const userId = await ctx.runMutation(internal.users.createOrGetUser, {
privyId: claims.userId,
address: address as string,
email: email as string
})

return {
userId
}
}
})
]
})
export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [
ConvexCredentials({
authorize: async (credentials, ctx) => {
const claims = await privy.verifyAuthToken(credentials.token as string)
const privyId = credentials.privyId
if (claims.userId !== privyId) {
throw new Error("Privy user ID mismatch")
}

const address = credentials.address || ""

const email = credentials.email
if (!email) {
throw new Error("No email found in credentials")
}

const userId = await ctx.runMutation(internal.users.createOrGetUser, {
privyId: claims.userId,
address: address as string,
email: email as string
})

return {
userId
}
}
})
]
})
export const createOrGetUser = internalMutation({
args: {
address: v.optional(v.string()),
email: v.string(),
profileImageUrl: v.optional(v.string()),
privyId: v.string()
},
handler: async (ctx, args) => {
const user = await Users.queryUserWithAuth(ctx)
if (user) {
return user._id
}

// Create new user if doesn't exist
const username = await Users.generateUniqueUsername(ctx)

const userId = await ctx.db.insert("users", {
address: args.address?.toLowerCase() || "",
email: args.email,
username,
socialLoginImageUrl: args.profileImageUrl,
privyId: args.privyId
})

return userId
}})
export const createOrGetUser = internalMutation({
args: {
address: v.optional(v.string()),
email: v.string(),
profileImageUrl: v.optional(v.string()),
privyId: v.string()
},
handler: async (ctx, args) => {
const user = await Users.queryUserWithAuth(ctx)
if (user) {
return user._id
}

// Create new user if doesn't exist
const username = await Users.generateUniqueUsername(ctx)

const userId = await ctx.db.insert("users", {
address: args.address?.toLowerCase() || "",
email: args.email,
username,
socialLoginImageUrl: args.profileImageUrl,
privyId: args.privyId
})

return userId
}})
erquhart
erquhart21h ago
I would add logs throughout to determine where the error is occurring if stack trace doesn't make it clear. I suspect the issue is in Users.queryUserWithAuth, but can't say for sure

Did you find this page helpful?