fix: GET /api/groups 빈 목록 시 200+[] 반환#344
Conversation
그룹이 없는 초기 환경에서 신청 폼 등이 즉시 오류 화면을 보이는 문제 수정. Empty는 에러가 아니므로 빈 리스트를 정상 응답으로 반환.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
GET /api/groups 호출 시 그룹이 0개인 초기 환경에서 404(NO_AVAILABLE_GROUPS)가 발생하던 동작을, REST 관행에 맞게 200 OK + 빈 리스트 반환으로 변경해 프론트엔드에서 즉시 오류 화면으로 전환되는 문제를 해소하려는 PR입니다.
Changes:
GroupService#getAllGroups()에서 “빈 목록이면 404 예외” 로직을 제거하여 빈 리스트를 그대로 반환하도록 변경- 관련 로그 흐름을 “0개 그룹” 케이스까지 자연스럽게 처리되도록 정리(예외 제거에 따른 기본 흐름 유지)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| log.info("[getAllGroups] 모든 그룹 정보 조회 시작"); | ||
| var groups = groupRepository.findAll(); | ||
|
|
||
| if (groups.isEmpty()) { | ||
| log.warn("[getAllGroups] 조회된 그룹 정보가 없습니다."); | ||
| throw new BusinessException(ErrorCode.NO_AVAILABLE_GROUPS); | ||
| } | ||
|
|
||
| var response = groups.stream() | ||
| .map(GroupResponseDTO::fromEntity) |
| log.info("[getAllGroups] 모든 그룹 정보 조회 시작"); | ||
| var groups = groupRepository.findAll(); | ||
|
|
||
| if (groups.isEmpty()) { | ||
| log.warn("[getAllGroups] 조회된 그룹 정보가 없습니다."); | ||
| throw new BusinessException(ErrorCode.NO_AVAILABLE_GROUPS); | ||
| } | ||
|
|
||
| var response = groups.stream() | ||
| .map(GroupResponseDTO::fromEntity) |
Summary
Closes #338
getAllGroups()에서 그룹이 없으면NO_AVAILABLE_GROUPS(404)를 던졌음.빈 컬렉션은 에러가 아니므로 빈 리스트(
[])를 200으로 반환하도록 수정.그룹이 없는 초기 환경에서 프론트엔드 신청 폼이 즉시 오류 화면을 보이는 문제가 해결됨.
Test plan
GET /api/groups→200 OK, body[]GET /api/groups→200 OK, body[{...}, ...]