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

[Bug]: TypeError: Cannot destructure property 'id' of 'raw' as it is null. #1701

Open
MahirAlam opened this issue Sep 28, 2024 · 3 comments
Open
Labels
bug Something ain't right...

Comments

@MahirAlam
Copy link

Package

​@lucia-auth/session-drizzle

Describe the bug

It is so sudden!

I checked everything all (everything was working). then, I pushed the code to github and then the production build showed an error (the error started showing in production when I changed the username and name by updating the DB) and when I ran the dev server same Kind of error was showing!

The error!

 ⨯ node_modules\@lucia-auth\adapter-drizzle\dist\drivers\postgresql.js (72:13) @ transformIntoDatabaseUser
 ⨯ TypeError: Cannot destructure property 'id' of 'raw' as it is null.
    at async $$ACTION_0 (./src/libs/auth.ts:60:20)
digest: "1922790224"
  70 | }
  71 | function transformIntoDatabaseUser(raw) {
> 72 |     const { id, ...attributes } = raw;
     |             ^
  73 |     return {
  74 |         id,
  75 |         attributes
 ⨯ node_modules\@lucia-auth\adapter-drizzle\dist\drivers\postgresql.js (72:13) @ transformIntoDatabaseUser
 ⨯ TypeError: Cannot destructure property 'id' of 'raw' as it is null.
    at async $$ACTION_0 (./src/libs/auth.ts:60:20)
digest: "1922790224"
  70 | }
  71 | function transformIntoDatabaseUser(raw) {
> 72 |     const { id, ...attributes } = raw;
     |             ^
  73 |     return {
  74 |         id,
  75 |         attributes

I also sometime get this message

tP [Error]: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options
    at Proxy.callable (E:\tera-tok\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:36:13125)
    at eval (webpack-internal:///(rsc)/./src/libs/auth.ts:62:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AuthLayout (webpack-internal:///(rsc)/./src/app/(auth)/layout.tsx:16:22)
tP [Error]: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options
    at Proxy.callable (E:\tera-tok\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:36:13125)
    at eval (webpack-internal:///(rsc)/./src/libs/auth.ts:62:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AuthLayout (webpack-internal:///(rsc)/./src/app/(auth)/layout.tsx:16:22)
I always ignore it.

I tried deleting the DB and tried loging in again e.t.c. but nothing worked!

@MahirAlam MahirAlam added the bug Something ain't right... label Sep 28, 2024
@ishaba
Copy link

ishaba commented Oct 29, 2024

Having the same issue after updating dependecies, trying to figure out which one cause the issue

@pilcrowonpaper
Copy link
Member

Sorry for the late response, what drivers are you using? @lucia-auth/adapter-drizzle uses pg for its tests and it's working fine

@pilcrowonpaper
Copy link
Member

I'm really confused with this since the error indicates the session is defined but the user isn't. I'm not sure how that's possible with an INNER JOIN.

const result = await this.db
	.select({
		user: this.userTable,
		session: this.sessionTable
	})
	.from(this.sessionTable)
	.innerJoin(this.userTable, eq(this.sessionTable.userId, this.userTable.id))
	.where(eq(this.sessionTable.id, sessionId));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something ain't right...
Projects
None yet
Development

No branches or pull requests

3 participants