fix: Redis TTL 조회 실패 시 rate limit 응답 안정화#663
Conversation
- 제한 초과 판단 이후 남은 시간 조회가 실패해도 servlet 예외로 전파되지 않도록 기본 window 값으로 대체한다 - 카운터 증가가 성공한 경우에는 제한 초과 상태를 유지해 Redis TTL 조회 장애가 요청 허용으로 바뀌지 않게 한다 - Redis timeout 재현 테스트를 추가해 동일한 500 전파가 재발하지 않도록 한다
|
Warning Review limit reached
More reviews will be available in 52 minutes and 17 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 Walkthrough개요RateLimitAspect에서 rate limit 초과 시 남은 시간을 조회하는 로직을 별도 메서드로 캡슐화하고 실패 시 폴백 처리를 추가했으며, 조회 실패 시나리오를 검증하는 테스트를 추가했습니다. 변경 사항Rate Limit TTL 조회 복원력
관련 PR
코드 리뷰 난이도🎯 2 (Simple) | ⏱️ ~12분 마치며
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/test/java/gg/agit/konect/unit/global/ratelimit/aspect/RateLimitAspectTest.java`:
- Around line 133-160: The test throws RateLimit exception but doesn't assert
that the TTL fallback (timeWindowSeconds = 60) is present in the exception
detail; update the assertion inside
throwsRateLimitExceptionWhenRemainingTimeLookupFails to also check the exception
detail message (e.g., call customEx.getDetail() or customEx.getFullMessage())
contains "60" to verify rateLimit.timeWindowSeconds() is used as the fallback
when rateLimitAspect.around fails to read TTL.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 840249dd-753a-4fe7-9308-3e229136e802
📒 Files selected for processing (2)
src/main/java/gg/agit/konect/global/ratelimit/aspect/RateLimitAspect.javasrc/test/java/gg/agit/konect/unit/global/ratelimit/aspect/RateLimitAspectTest.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: coverage
- GitHub Check: Code Style Check
- GitHub Check: Analyze (java-kotlin)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.java
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.java: Java 코드에서 import로 해결할 수 있는 경우 FQCN(Full Qualified Class Name)을 사용하지 않도록 지적한다
JPA/QueryDSL 조회 변경 시 N+1, 잘못된 fetch join, count 쿼리 왜곡, pagination 깨짐, distinct 누락을 확인한다
권한 로직은 관리자 우회, 요청자와 대상자 관계, 클럽/채팅방/공지/일정의 소속 검증이 빠지지 않았는지 확인한다
soft delete, 탈퇴 사용자, 차단/제외 조건, 중복 제거가 필요한 조회에서는 응답에 노출되면 안 되는 데이터가 포함되는지 확인한다
DTO 응답 변경은 기존 클라이언트가 기대하는 필드명, nullability, enum/string 값, 정렬 순서를 깨지 않는지 확인한다
조건이 2개 이상 결합된 비즈니스 규칙, 권한 조건, soft delete 제외, 중복 제거, fallback 우선순위, 대표값 선택, DTO 변환, count 쿼리 분리, fetch join 선택 이유처럼 코드만으로 의도가 숨겨지는 지점에는 주석을 권장한다
단순 생성자 호출, 필드 매핑, 컬렉션 반환, 이름만으로 명확한 분기에는 주석을 요구하지 않는다
Files:
src/main/java/gg/agit/konect/global/ratelimit/aspect/RateLimitAspect.javasrc/test/java/gg/agit/konect/unit/global/ratelimit/aspect/RateLimitAspectTest.java
**/*.{sql,java}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
데이터베이스 변경에서는 마이그레이션 순서, 기존 데이터 호환성, nullable/default 처리, 롤백 난이도, 인덱스 필요성을 확인한다
Files:
src/main/java/gg/agit/konect/global/ratelimit/aspect/RateLimitAspect.javasrc/test/java/gg/agit/konect/unit/global/ratelimit/aspect/RateLimitAspectTest.java
src/main/java/**/*.java
⚙️ CodeRabbit configuration file
src/main/java/**/*.java: 아래 원칙으로 리뷰 코멘트를 작성한다.
- 코멘트는 반드시 한국어로 작성한다.
- 반드시 수정이 필요한 항목만 코멘트로 남기고, 단순 취향 차이는 지적하지 않는다.
- 각 코멘트 첫 줄에 심각도를
[LEVEL: high|medium|low]형식으로 반드시 표기한다.- 심각도 기준: high=운영 장애 가능, medium=품질 저하, low=개선 권고.
- 각 코멘트는 "문제 -> 영향 -> 제안" 순서로 3문장 이내로 간결하게 작성한다.
- 가능하면 재현 조건 및 실패 시나리오도 포함한다.
- 제안은 현재 코드베이스(Spring Boot + JPA + Flyway) 패턴과 일치해야 한다.
- 보안, 트랜잭션 경계, 예외 처리, N+1, 성능 회귀 가능성을 우선 점검한다.
- 가독성: 변수/메서드 이름이 의도를 바로 드러내는지, 중첩과 메서드 길이가 과도하지 않은지 점검한다.
- 단순화: 불필요한 추상화, 중복 로직, 과한 방어 코드가 있으면 더 단순한 대안을 제시한다.
- 확장성: 새 요구사항 추가 시 변경 범위가 최소화되는 구조인지(하드코딩 분기/값 여부 포함) 점검한다.
Files:
src/main/java/gg/agit/konect/global/ratelimit/aspect/RateLimitAspect.java
**/*
⚙️ CodeRabbit configuration file
**/*: 공통 리뷰 톤 가이드:
- 모든 코멘트는 첫 줄에
[LEVEL: ...]태그를 포함한다.- 과장된 표현 없이 사실 기반으로 작성한다.
- 한 코멘트에는 하나의 이슈만 다룬다.
- 코드 예시가 필요하면 최소 수정 예시를 제시한다.
- 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.
Files:
src/main/java/gg/agit/konect/global/ratelimit/aspect/RateLimitAspect.javasrc/test/java/gg/agit/konect/unit/global/ratelimit/aspect/RateLimitAspectTest.java
🔇 Additional comments (1)
src/main/java/gg/agit/konect/global/ratelimit/aspect/RateLimitAspect.java (1)
74-74: LGTM!Also applies to: 128-140
🧪 JaCoCo Coverage Report (Changed Files)Summary
Coverage by File
|
- 리뷰 피드백에 따라 TTL 조회 실패 시 기본 window 값이 예외 detail에 반영되는지 확인한다 - 429 에러 코드만 검증하던 테스트를 보강해 fallback 시간이 응답 메시지에서 누락되는 회귀를 막는다
🔍 개요
🚀 주요 변경 내용
timeWindowSeconds를 fallback 값으로 사용했습니다.TOO_MANY_REQUESTS응답이 유지되는 단위 테스트를 추가했습니다.💬 참고 사항
CI=true ./gradlew test --tests '*RateLimitAspectTest'./gradlew checkstyleMaingit diff --checkcheckstyleMain,compileJava가 통과했습니다../gradlew checkstyleTest는 기존 unrelated 테스트 파일의 line length 위반으로 실패합니다.✅ Checklist (완료 조건)