Skip to content

[Bug] UserDetails가 null인 경우 발생하는 오류 수정 요청 #9

@Duskafka

Description

@Duskafka

🐞 버그 리포트

😕 버그 설명

  • @AuthenticationPrincipal애노테이션으로 받아온 UserDetails객체가 null일 수 있음.
  • 하지만 null인 상태로 비즈니스 로직에 들어가면 NullPointException등 오류를 일으킴.
  • 만약 null이 받아와졌다면 403 상태코드를 반환하는 처리가 필요함.

♾️ 재현 방법

StudentApiController에 로그인 후 요청을 보낼 때 토큰 정보를 담지 않고 보내면 됨.

🤔 기대한 동작

  • 성공: UserDetails에서 username 필드를 가져와 비즈니스 로직에서 사용.

⚠️ 실제 동작

  • UserDetails가 null이라서 username필드를 가져올 수 없음. 따라서 null값이 비즈니스 로직에 들어감.
  • NullPointException이 발생함.

Metadata

Metadata

Assignees

Labels

bug버그(또는 에러)가 발생하여 수정이 필요합니다.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions