DevbenD
Convex Community2y ago
33 replies
Devben

convex auth: Unable to decode ID: Invalid ID length 5

I'm trying to get the current user but it's returning undefine am using nextjs and i follow the nextjs step, but when i change the convexnextjsauthprovide to authprovider i see the user however am seeing this error.

Uncaught (in promise) Error: [Request ID: 5dfe7ffe2f531b80] Server Error Uncaught Error: Uncaught Error: Invalid argument id for db.get: Unable to decode ID: Invalid ID length 5

my current user function


import { query } from "./_generated/server";
import { auth } from "./auth";

export const currentUser = query({
args: {},
handler: async (ctx) => {
const userId = await auth.getUserId(ctx);

if (userId === null || userId.length < 5) {
console.log("Invalid user ID");
return null;
}

return await ctx.db.get(userId);
},
});

@erquhart bro check this out.
Was this page helpful?