AntoineA67 / ft_transcendence

4 stars 1 forks source link

Backend errors #197

Closed Florian-A closed 12 months ago

Florian-A commented 12 months ago
[Nest] 765  - 11/13/2023, 3:59:17 PM   ERROR [WsExceptionsHandler]
Invalid `this.prisma.user.findUnique()` invocation in
/app/dist/users/users.service.js:178:39

  175     return (user.username);
  176 }
  177 async getUserById(id) {
→ 178     return await this.prisma.user.findUnique({
            where: {
              id: [
                1,
                2
              ]
              ~~~
            },
            select: {
              id: true,
              email: true,
              username: true,
              avatar: true,
              status: true,
              activated2FA: true
            }
          })

Argument `id`: Invalid value provided. Expected Int, provided (Int, Int).
[Nest] 765  - 11/13/2023, 3:59:02 PM   ERROR [ExceptionsHandler]
Invalid `this.prisma.achievement.upsert()` invocation in
/app/dist/achievement/achievement.service.js:22:55

  19     this.playerService = playerService;
  20 }
  21 async getAchieveById(id) {
→ 22     const achieve = await this.prisma.achievement.upsert(
Unique constraint failed on the fields: (`userId`)
PrismaClientKnownRequestError:
Invalid `this.prisma.achievement.upsert()` invocation in
/app/dist/achievement/achievement.service.js:22:55

  19     this.playerService = playerService;
  20 }
  21 async getAchieveById(id) {
→ 22     const achieve = await this.prisma.achievement.upsert(
Unique constraint failed on the fields: (`userId`)
    at Cn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:123:6817)
    at Cn.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:123:6206)
    at Cn.request (/app/node_modules/@prisma/client/runtime/library.js:123:5926)
    at async l (/app/node_modules/@prisma/client/runtime/library.js:128:9968)
    at async AchievementService.getAchieveById (/app/dist/achievement/achievement.service.js:22:25)
    at async ProfileService.getUserProfileById (/app/dist/profile/profile.service.js:34:25)
    at async ProfileController.getMyProfile (/app/dist/profile/profile.controller.js:28:25)
    at async /app/node_modules/@nestjs/core/router/router-execution-context.js:46:28
    at async /app/node_modules/@nestjs/core/router/router-proxy.js:9:17
[Nest] 765  - 11/13/2023, 3:57:20 PM   ERROR [WsExceptionsHandler]
Invalid `this.prisma.user.findUnique()` invocation in
/app/dist/users/users.service.js:178:39

  175     return (user.username);
  176 }
  177 async getUserById(id) {
→ 178     return await this.prisma.user.findUnique({
            where: {
              id: undefined,
          ?   username?: String,
          ?   email?: String,
          ?   AND?: UserWhereInput | UserWhereInput[],
          ?   OR?: UserWhereInput[],
          ?   NOT?: UserWhereInput | UserWhereInput[],
          ?   status?: EnumOnlineStatusFilter | OnlineStatus,
          ?   firstConnexion?: StringFilter | String,
          ?   hashPassword?: StringNullableFilter | String | Null,
          ?   u2fHash?: StringNullableFilter | String | Null,
          ?   otpHash?: StringNullableFilter | String | Null,
          ?   activated2FA?: BoolFilter | Boolean,
          ?   avatar?: StringNullableFilter | String | Null,
          ?   avatar42?: StringNullableFilter | String | Null,
          ?   bio?: StringFilter | String,
          ?   gameSettings?: GameSettingsNullableRelationFilter | GameSettingsWhereInput | Null,
          ?   achieve?: AchievementNullableRelationFilter | AchievementWhereInput | Null,
          ?   gameHistory?: PlayerListRelationFilter,
          ?   membership?: MemberListRelationFilter,
          ?   message?: MessageListRelationFilter,
          ?   friend?: FriendshipListRelationFilter,
          ?   sendFriendReq?: FriendRequestListRelationFilter,
          ?   recvFriendReq?: FriendRequestListRelationFilter,
          ?   block?: BlockListRelationFilter,
          ?   blocked?: BlockListRelationFilter,
          ?   refreshToken?: RefreshTokenListRelationFilter
            },
            select: {
              id: true,
              email: true,
              username: true,
              avatar: true,
              status: true,
              activated2FA: true
            }
          })

Argument `where` of type UserWhereUniqueInput needs at least one of `id`, `id`, `username` or `email` arguments. Available options are marked with ?.
PrismaClientValidationError:
Invalid `this.prisma.user.findUnique()` invocation in
/app/dist/users/users.service.js:178:39

  175     return (user.username);
  176 }
  177 async getUserById(id) {
→ 178     return await this.prisma.user.findUnique({
            where: {
              id: undefined,
          ?   username?: String,
          ?   email?: String,
          ?   AND?: UserWhereInput | UserWhereInput[],
          ?   OR?: UserWhereInput[],
          ?   NOT?: UserWhereInput | UserWhereInput[],
          ?   status?: EnumOnlineStatusFilter | OnlineStatus,
          ?   firstConnexion?: StringFilter | String,
          ?   hashPassword?: StringNullableFilter | String | Null,
          ?   u2fHash?: StringNullableFilter | String | Null,
          ?   otpHash?: StringNullableFilter | String | Null,
          ?   activated2FA?: BoolFilter | Boolean,
          ?   avatar?: StringNullableFilter | String | Null,
          ?   avatar42?: StringNullableFilter | String | Null,
          ?   bio?: StringFilter | String,
          ?   gameSettings?: GameSettingsNullableRelationFilter | GameSettingsWhereInput | Null,
          ?   achieve?: AchievementNullableRelationFilter | AchievementWhereInput | Null,
          ?   gameHistory?: PlayerListRelationFilter,
          ?   membership?: MemberListRelationFilter,
          ?   message?: MessageListRelationFilter,
          ?   friend?: FriendshipListRelationFilter,
          ?   sendFriendReq?: FriendRequestListRelationFilter,
          ?   recvFriendReq?: FriendRequestListRelationFilter,
          ?   block?: BlockListRelationFilter,
          ?   blocked?: BlockListRelationFilter,
          ?   refreshToken?: RefreshTokenListRelationFilter
            },
            select: {
              id: true,
              email: true,
              username: true,
              avatar: true,
              status: true,
              activated2FA: true
            }
          })

Argument `where` of type UserWhereUniqueInput needs at least one of `id`, `id`, `username` or `email` arguments. Available options are marked with ?.
    at En (/app/node_modules/@prisma/client/runtime/library.js:116:5888)
    at Cn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:123:6516)
    at Cn.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:123:6206)
    at Cn.request (/app/node_modules/@prisma/client/runtime/library.js:123:5926)
    at async l (/app/node_modules/@prisma/client/runtime/library.js:128:9968)
    at async UsersService.getUserById (/app/dist/users/users.service.js:178:16)
    at async UsersGateway.handleGetUser (/app/dist/users/users.gateway.js:113:16)
    at async UsersGateway.<anonymous> (/app/node_modules/@nestjs/websockets/context/ws-proxy.js:12:32)
    at async WebSocketsController.pickResult (/app/node_modules/@nestjs/websockets/web-sockets-controller.js:96:24)
[Nest] 765  - 11/13/2023, 4:05:00 PM   ERROR [WsExceptionsHandler] Cannot read properties of undefined (reading 'password')
TypeError: Cannot read properties of undefined (reading 'password')
    at UsersService.updateUser (/app/dist/users/users.service.js:123:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async UsersGateway.handleUpdateProfile (/app/dist/users/users.gateway.js:49:17)
[Nest] 762  - 11/13/2023, 4:20:52 PM     LOG [Game Gateway] getMyGameSettings
[Nest] 762  - 11/13/2023, 4:20:52 PM     LOG [ProfileGateway] MyProfile
[Nest] 762  - 11/13/2023, 4:20:55 PM     LOG [Game Gateway] getMyGameSettings
[Nest] 762  - 11/13/2023, 4:20:55 PM     LOG [Game Gateway] getMyGameSettings
/app/dist/game/Room.class.js:70
            if (players[0].score > players[1].score) {
                                              ^

TypeError: Cannot read properties of undefined (reading 'score')
    at Room.updateGameTick (/app/dist/game/Room.class.js:70:47)
    at Timeout._onTimeout (/app/dist/game/Room.class.js:50:18)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)

Node.js v20.9.0
npm WARN deprecated @apollo/server-plugin-landing-page-graphql-playground@4.0.0: The use of GraphQL Playground in Apollo Server was supported in previous versions, but this is no longer the case as of December 31, 2022. This package exists for v4 migration purposes only. We do not intend to resolve security issues or other bugs with this package if they arise, so please migrate away from this to [Apollo Server's default Explorer](https://www.apollographql.com/docs/apollo-server/api/plugin/landing-pages) as soon as possible.
npm WARN deprecated subscriptions-transport-ws@0.11.0: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws    For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md

added 898 packages, and audited 899 packages in 12s

122 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Prisma schema loaded from schema.prisma
Datasource "db": PostgreSQL database "transcendence", schema "public" at "db:5432"

The PostgreSQL database "transcendence" schema "public" at "db:5432" was successfully reset.

🚀  Your database is now in sync with your Prisma schema. Done in 185ms

✔ Generated Prisma Client (v5.5.2) to ./../../node_modules/@prisma/client in 325
ms

Running seed command `ts-node seed.ts` ...

🌱  The seed command has been executed.
Prisma schema loaded from schema.prisma

✔ Generated Prisma Client (v5.5.2) to ./../../node_modules/@prisma/client in 385ms

Start using Prisma Client in Node.js (See: https://pris.ly/d/client)

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()

See other ways of importing Prisma Client: http://pris.ly/d/importing-client

> nestjs-backend@0.0.1 build
> nest build
alpyt42 commented 12 months ago
[Nest] 755  - 11/13/2023, 5:01:29 PM   ERROR [ExceptionsHandler] 
Invalid `this.prisma.achievement.upsert()` invocation in
/app/dist/achievement/achievement.service.js:22:55

  19     this.playerService = playerService;
  20 }
  21 async getAchieveById(id) {
→ 22     const achieve = await this.prisma.achievement.upsert(
Unique constraint failed on the fields: (`userId`)
PrismaClientKnownRequestError: 
Invalid `this.prisma.achievement.upsert()` invocation in
/app/dist/achievement/achievement.service.js:22:55

  19     this.playerService = playerService;
  20 }
  21 async getAchieveById(id) {
→ 22     const achieve = await this.prisma.achievement.upsert(
Unique constraint failed on the fields: (`userId`)
    at Cn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:123:6817)
    at Cn.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:123:6206)
    at Cn.request (/app/node_modules/@prisma/client/runtime/library.js:123:5926)
    at async l (/app/node_modules/@prisma/client/runtime/library.js:128:9968)
    at async AchievementService.getAchieveById (/app/dist/achievement/achievement.service.js:22:25)
    at async ProfileService.getUserProfileById (/app/dist/profile/profile.service.js:34:25)
    at async ProfileController.getMyProfile (/app/dist/profile/profile.controller.js:28:25)
    at async /app/node_modules/@nestjs/core/router/router-execution-context.js:46:28
    at async /app/node_modules/@nestjs/core/router/router-proxy.js:9:17
alpyt42 commented 12 months ago

Supprimer les Logger.log aussi !!

alpyt42 commented 12 months ago

To fix:

Game:

Parties a fix :