Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
| @@ -0,0 +1,5 @@ | |||
| package com.nexters.gotggam.toss.client; | |||
|
|
|||
| public record TossApiError(String errorCode, String reason) { | |||
There was a problem hiding this comment.
응답 형식 문서를 봤을 땐 에러 객체에 errorType, data, title도 있고, 요청 한도를 초과하면 HTTP 200에 errorCode: "4095"와 error.data.retryAfterSeconds가 내려간다고 써있던데 일부러 errorCode랑 reason만 받도록 의도하신 건지 궁금합니다!
There was a problem hiding this comment.
분기에 필요한 errorCode와 로깅용 reason만 의도적으로 받았습니다!
요청 한도 초과는 errorCode: 4095로 판단해 TOSS_003(429)으로 변환하고 있습니다. data 안의 retryAfterSeconds도 고민해봤는데, 토스 api 호출은 백엔드 내부에서 처리되는 부분이라 프론트에 전달하는 건 과하다고 생각했고, 로그에 남기기에도 불필요하다고 판단했습니다.
백엔드 내부 재시도에 활용할 여지는 있지만, 아직 토스에 미니앱으로 등록하지 않은 상태라 retryAfterSeconds 규모를 아직 알 수 없어서 지금 시점에서 재시도 전략을 정하기 어려웠습니다 ㅜ 실제로 4095가 발생하면 그때 값을 보고 추가하려고 합니다!
📌 개요 (why, what)
resultType/success/error공통 형식으로 감싸고, 비즈니스 오류도 HTTP 200 +resultType: FAIL로 응답합니다.TossApiClient를 추가했습니다.develop으로 변경하겠습니다.🛠️ 구현 방법 (how)
toss패키지 (최상위)toss/client—TossApiResponse,TossApiError: 공통 응답 형식 recordtoss/client—TossApiClient.post(uri, body, responseType): 성공 시success값만 반환하고, 실패 시BusinessException으로 변환합니다.TOSS_001(503)resultType이SUCCESS가 아님TOSS_002(502)errorCode: 4095)TOSS_003(429)errorCode기준으로 위와 동일TOSS_002(502)SUCCESS인데success가 nullTOSS_002(502)errorCode/reason은 로그에만 남기고 클라이언트에는 노출하지 않습니다.toss/exception—TossErrorCode가BaseError를 구현해 기존GlobalExceptionHandler흐름을 그대로 탑니다.기타
TossApiClientConfig,TossApiProperties를global/config→toss/client로 이동했습니다. ([chore] 앱인토스 mTLS 인증서 및 미니앱 CORS 설정 #76 CodeRabbit 리뷰 반영:global에는 전역 공통 설정만 둔다는 컨벤션)RestClient.Builder를 주입받도록 변경했습니다. (공통 Jackson 설정·Observation 적용)RestClient.Builder자동 구성이 별도 모듈이라spring-boot-starter-restclient의존성을 추가했습니다. 없으면 prod 기동 시 빈을 찾지 못합니다..gitignore에*.key,*.crt,*.pem을 추가했습니다.검증
MockRestServiceServer기반 단위 테스트 7개 (위 표의 케이스)4050)이TossApiResponse로 역직렬화되고TOSS_002로 변환되는 것을 확인했습니다.🤔 검토한 대안과 선택 이유 (trade-off)
resultType직접 확인errorCode(예: 4095)를 잃음💭 리뷰 포인트
toss패키지 위치toss패키지로 분리했습니다. (client,exception하위 구조는 기존 도메인과 동일)TossErrorCodeHTTP 상태📚 Reference (Optional)
🤖 Generated with Claude Code