Repository navigation
fix: 없는 자원 조회가 500 이 아니라 404 가 되도록 - #136
Merged
Merged
Conversation
CareServiceException 의 기본 매핑은 500 이다(핸들러가 아는 코드가 아니면 INTERNAL_SERVER_ERROR). 그런데 서비스들이 '찾을 수 없습니다' 를 이 예외로 던지는 곳이 34군데였다. 없는 시설 ID 로 입소 예측·인기도·대기 통계를 조회하면 500 이 나가고 운영 알림까지 울렸다. 클라이언트는 '내가 잘못 보냈다' 와 '서버가 고장났다' 를 구분할 수 없고, 운영 문서가 경계하는 바로 그 상황이 된다 — 봇이 긁고 가면 알림이 울리고 진짜 장애가 그 소음에 묻힌다. - 34곳(15개 파일)을 ResourceNotFoundException(404 매핑)으로 교체 - 더 이상 쓰지 않게 된 CareServiceException import 정리 - ClientErrorStatusTest 에 '없는 자원은 404, 운영 알림 없음' 추가 ResourceNotFoundException 은 CareCodeException 을 상속하고, HealthService 같은 곳의 catch(Exception) 래핑보다 앞선 catch(CareCodeException) 에서 재던져지므로 래핑에 먹히지 않는다. 그 사실도 테스트가 함께 검증한다(통과 전에는 expected 404 but was 500 이었다).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #132 (2단계)
버그
CareServiceException의 기본 매핑은 500 이다(핸들러가 아는 코드가 아니면INTERNAL_SERVER_ERROR). 그런데 서비스들이 "찾을 수 없습니다" 를 이 예외로 던지는 곳이 34군데였다.전부 공개 엔드포인트다. 봇이 긁고 가면 500 이 쌓이고 운영 알림이 울린다 — 운영 문서가 경계하는 "진짜 장애가 소음에 묻히는" 상황이다. 클라이언트도 자기 잘못인지 서버 잘못인지 알 수 없다.
순서
expected: 404 but was: 500ResourceNotFoundException으로 교체래핑에 먹히지 않는 이유
ResourceNotFoundException extends CareCodeException이고,HealthService같은 곳의catch (Exception)앞에catch (CareCodeException) { throw e; }가 있어 그대로 올라간다. 이 사실도 테스트가 검증한다(교체 전에는 같은 테스트가 500 으로 실패했다).남은 예외 정리
이 PR 은 "없는 자원" 한 종류만 다룬다. 남은 것:
catch (Exception e)로 원인을 덮어쓰는 블록 — ChatbotService 11회, HealthService 10회CareServiceException96 → 62로 줄었다)테스트
전체 601 tests, 실패 0, skip 0