인프런 커뮤니티 질문&답변

작성자 없음

작성자 정보가 삭제된 글입니다.

맛집 지도앱 만들기 (React Native + NestJS)

[3-8] React Query 도입(2) - 로그인 연동하기

회원가입시 QueryFailedError 에러

해결된 질문

작성

·

300

1

회원가입시 이러한 에러가 계속 발생합니다.

 

console.log로

test@test.com qwer1234

email, password는 들어가는것도 확인했고 auth/signup error를 catch했을땐 409code로 에러가 들어왔습니다.

무엇이 문제일까요...?

중복이 문제인가 싶어 다른 여러 아이디로도 해봤는데 계속해서 저러한 에러가 뜨면서 실패하고있습니다ㅜㅜ

 

QueryFailedError: duplicate key value violates unique constraint "UQ_e12875dfb3b1d92d7d7c5377e22"
    at PostgresQueryRunner.query (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/driver/postgres/PostgresQueryRunner.ts:331:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at InsertQueryBuilder.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/query-builder/InsertQueryBuilder.ts:163:33)
    at SubjectExecutor.executeInsertOperations (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/SubjectExecutor.ts:435:42)
    at SubjectExecutor.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/SubjectExecutor.ts:137:9)
    at EntityPersistExecutor.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/EntityPersistExecutor.ts:182:21)
    at AuthService.signup (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/auth/auth.service.ts:43:7)
    at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/@nestjs/core/router/router-execution-context.js:46:28
    at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/@nestjs/core/router/router-proxy.js:9:17 {
  query: 'INSERT INTO "user"("loginType", "email", "password", "nickname", "imageUri", "kakaoImageUri", "RED", "YELLOW", "GREEN", "BLUE", "PURPLE", "createdAt", "updatedAt", "deletedAt", "hashedRefreshToken") VALUES ($1, $2, $3, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "id", "RED", "YELLOW", "GREEN", "BLUE", "PURPLE", "createdAt", "updatedAt", "deletedAt"',
  parameters: [
    'email',
    'test@test.com',
    '$2a$10$hlFtQkbll6R0pJNkTywGh.DaRGVm1uhu9DJm9c.Q0OeduuMRzdNyK'
  ],
  driverError: error: duplicate key value violates unique constraint "UQ_e12875dfb3b1d92d7d7c5377e22"
      at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/pg/lib/client.js:526:17
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at PostgresQueryRunner.query (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/driver/postgres/PostgresQueryRunner.ts:260:25)
      at InsertQueryBuilder.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/query-builder/InsertQueryBuilder.ts:163:33)
      at SubjectExecutor.executeInsertOperations (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/SubjectExecutor.ts:435:42)
      at SubjectExecutor.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/SubjectExecutor.ts:137:9)
      at EntityPersistExecutor.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/EntityPersistExecutor.ts:182:21)
      at AuthService.signup (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/auth/auth.service.ts:43:7)
      at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/@nestjs/core/router/router-execution-context.js:46:28
      at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/@nestjs/core/router/router-proxy.js:9:17 {
    length: 234,
    severity: 'ERROR',
    code: '23505',
    detail: 'Key (email)=(test@test.com) already exists.',
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: 'public',
    table: 'user',
    column: undefined,
    dataType: undefined,
    constraint: 'UQ_e12875dfb3b1d92d7d7c5377e22',
    file: 'nbtinsert.c',
    line: '670',
    routine: '_bt_check_unique'
  },
  length: 234,
  severity: 'ERROR',
  code: '23505',
  detail: 'Key (email)=(test@test.com) already exists.',
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: 'public',
  table: 'user',
  column: undefined,
  dataType: undefined,
  constraint: 'UQ_e12875dfb3b1d92d7d7c5377e22',
  file: 'nbtinsert.c',
  line: '670',
  routine: '_bt_check_unique'
}
QueryFailedError: duplicate key value violates unique constraint "UQ_e12875dfb3b1d92d7d7c5377e22"
    at PostgresQueryRunner.query (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/driver/postgres/PostgresQueryRunner.ts:331:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at InsertQueryBuilder.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/query-builder/InsertQueryBuilder.ts:163:33)
    at SubjectExecutor.executeInsertOperations (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/SubjectExecutor.ts:435:42)
    at SubjectExecutor.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/SubjectExecutor.ts:137:9)
    at EntityPersistExecutor.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/EntityPersistExecutor.ts:182:21)
    at AuthService.signup (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/auth/auth.service.ts:43:7)
    at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/@nestjs/core/router/router-execution-context.js:46:28
    at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/@nestjs/core/router/router-proxy.js:9:17 {
  query: 'INSERT INTO "user"("loginType", "email", "password", "nickname", "imageUri", "kakaoImageUri", "RED", "YELLOW", "GREEN", "BLUE", "PURPLE", "createdAt", "updatedAt", "deletedAt", "hashedRefreshToken") VALUES ($1, $2, $3, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "id", "RED", "YELLOW", "GREEN", "BLUE", "PURPLE", "createdAt", "updatedAt", "deletedAt"',
  parameters: [
    'email',
    'test@test.com',
    '$2a$10$DfBqqh82WjRRFN5Fj2zJu.RiqJzzJCD4vR5xA1.y2zRxaAol0pP6W'
  ],
  driverError: error: duplicate key value violates unique constraint "UQ_e12875dfb3b1d92d7d7c5377e22"
      at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/pg/lib/client.js:526:17
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at PostgresQueryRunner.query (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/driver/postgres/PostgresQueryRunner.ts:260:25)
      at InsertQueryBuilder.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/query-builder/InsertQueryBuilder.ts:163:33)
      at SubjectExecutor.executeInsertOperations (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/SubjectExecutor.ts:435:42)
      at SubjectExecutor.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/SubjectExecutor.ts:137:9)
      at EntityPersistExecutor.execute (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/persistence/EntityPersistExecutor.ts:182:21)
      at AuthService.signup (/Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/src/auth/auth.service.ts:43:7)
      at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/@nestjs/core/router/router-execution-context.js:46:28
      at /Users/kwonbeomjun/Documents/rn/rn-baro_review-v1/server/node_modules/@nestjs/core/router/router-proxy.js:9:17 {
    length: 234,
    severity: 'ERROR',
    code: '23505',
    detail: 'Key (email)=(test@test.com) already exists.',
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: 'public',
    table: 'user',
    column: undefined,
    dataType: undefined,
    constraint: 'UQ_e12875dfb3b1d92d7d7c5377e22',
    file: 'nbtinsert.c',
    line: '670',
    routine: '_bt_check_unique'
  },
  length: 234,
  severity: 'ERROR',
  code: '23505',
  detail: 'Key (email)=(test@test.com) already exists.',
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: 'public',
  table: 'user',
  column: undefined,
  dataType: undefined,
  constraint: 'UQ_e12875dfb3b1d92d7d7c5377e22',
  file: 'nbtinsert.c',
  line: '670',
  routine: '_bt_check_unique'
}

답변 2

1

해결하였습니다.. 지워지지가 않군요!
엔드포인드를 signup으로 2개 보내고있었네요ㅜㅜ

Kyo님의 프로필 이미지
Kyo
지식공유자

앗 해결하셨다니 다행입니다 👍 또 막히는 부분 있다면 알려주세요!

0

안녕하세요! 저도 같은 문제를 겪고있는데 해결 방법 조금만 더 상세히 알려주실 수 있을까요?

감사합니다!

아아.. 눈물겹게 해결했습니다.

front > src > api > auth.ts 파일에서 postLogin에 '/auth/signin'을 '/auth/signup'으로 잘못 설정했네요. 위에 분이 하신 말씀이 이거였군요.

어디를 살펴봐야 하는지 힌트주셔서 감사합니다ㅠㅠ

이제봤네요..ㅜㅜ 해결하셨다니 다행입니다~!

작성자 없음

작성자 정보가 삭제된 글입니다.

질문하기