잘못된 형태의 요청이 500+Slack/Sentry 알림으로 새던 문제 수정 - #254
Merged
Conversation
prod Grafana 로그 확인 결과 최근 7일간 5xx 40건이 전부 정상 앱 트래픽이 아니라 Postman 등으로 잘못된 메서드/형식을 직접 찌른 요청(GET /api/auth, 잘못된 Content-Type의 POST /api/auth)과 취약점 스캐너 프로빙(.env, /etc/passwd 경로 접근 시도)이었다. 원래 405/415/406으로 응답해야 할 요청인데, ControllerExceptionAdvice의 범용 Exception 핸들러가 전부 500으로 뭉개고 Slack/Sentry 알림까지 매번 보내고 있었다 — 실제 장애가 아닌데 알림만 계속 쌓이는 구조. HttpRequestMethodNotSupportedException(405)/HttpMediaTypeNotSupportedException (415)/HttpMediaTypeNotAcceptableException(406) 전용 핸들러를 추가해 WARN 로그만 남기고 정상 상태 코드로 응답하도록 분리했다. 406은 본문(JSON)을 만들려는 시도 자체가 다시 협상 실패로 이어질 수 있어(실제 로그에서 "Failure in @ExceptionHandler" 이중 오류로 확인) 본문 없이 상태 코드만 응답한다. MockMvc로 수정 전 실제로 500이 나고, 수정 후 405/415가 나며 Slack 알림이 호출되지 않음을 재현 테스트로 검증했다.
unam98
requested review from
RinRinPARK,
YuSuhwa-ve and
funnysunny08
as code owners
August 24, 2026 07:13
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 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 |
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.
작업 배경
.env//etc/passwd/.aws/credentials경로를 노리는 취약점 스캐너 프로빙이었다 — 실제 장애가 아니라 클라이언트(또는 봇)가 잘못 요청한 것.ControllerExceptionAdvice의 범용@ExceptionHandler(Exception.class)가 500으로 응답하고 Slack/Sentry 알림까지 매번 보내고 있어, 진짜 장애가 아닌데 알림만 계속 쌓이는 구조였다.변경 사항
ErrorStatusINVALID_HTTP_METHOD_EXCEPTION(405),UNSUPPORTED_MEDIA_TYPE_EXCEPTION(415) 추가ControllerExceptionAdviceHttpRequestMethodNotSupportedException(405),HttpMediaTypeNotSupportedException(415),HttpMediaTypeNotAcceptableException(406) 전용 핸들러 추가 — WARN 로그만 남기고 Slack/Sentry는 호출하지 않음406(
HttpMediaTypeNotAcceptableException)은 응답 본문(JSON)을 만들려는 시도 자체가 다시 협상 실패로 이어질 수 있어(실제 prod 로그에서Failure in @ExceptionHandler ... handleException→DefaultHandlerExceptionResolver로 전파되는 이중 오류를 확인) 본문 없이 상태 코드만 응답하도록 분리했다.영향 범위
검증 매트릭스
지원하지_않는_메서드지원하지_않는_컨텐츠타입두 테스트 모두 수정 전 코드에 대해 먼저 실행해 실제로 500이 나는 것을 확인한 뒤, 수정 후 405/415로 정상화되고 Slack 알림이 호출되지 않음을 재검증했다.
Test Plan
🤖 Generated with Claude Code