Skip to content

fix: 로그인 실패 시 401 에러 반환 #106

Description

@lilloo04

📌 개요

  • 현재 로그인이 필요한 API 호출 시 토큰이 없거나 유효하지 않으면 NullPointerException이 발생하여 500 Internal Server Error가 반환됨.
  • 프론트엔드에서 적절히 처리할 수 없는 문제

🔍 상세 내용

  • 에러 메시지: Cannot invoke "com.comma.soomteum.domain.user.entity.User.getUserId()" because "user" is null
  • HTTP 상태 코드: 500 Internal Server Error

원인

  1. LoginUserArgumentResolver.java:38-40에서 토큰이 없거나 유효하지 않을 때 null을 반환
  2. 컨트롤러에서 User 객체를 주입받은 후 user.getUserId() 호출 시 NullPointerException 발생
  3. 예외 처리되지 않아 500 에러로 반환 ### 해결 방안
    LoginUserArgumentResolver에서 토큰이 유효하지 않을 때 null 대신 명확한 예외(CustomException(ErrorCode.INVALID_LOGIN))를 던져서 401 Unauthorized 에러를 반환하도록 수정

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions