-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: 회원 탈퇴 재가입 처리 개선 및 OAuth/AI 리뷰 에러 해결 #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| import org.ezcode.codetest.domain.submission.exception.code.CodeReviewExceptionCode; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.http.HttpHeaders; | ||
| import org.springframework.http.HttpStatusCode; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.interceptor.TransactionAspectSupport; | ||
|
|
@@ -30,10 +31,10 @@ | |
| @RequiredArgsConstructor | ||
| public class OpenAIReviewClient implements ReviewClient { | ||
|
|
||
| @Value("${OPEN_API_URL}") | ||
| @Value("${openai.api.url}") | ||
| private String openApiUrl; | ||
|
|
||
| @Value("${OPEN_API_KEY}") | ||
| @Value("${openai.api.key}") | ||
| private String openApiKey; | ||
| private WebClient webClient; | ||
| private final OpenAIMessageBuilder openAiMessageBuilder; | ||
|
|
@@ -77,7 +78,6 @@ public ReviewResult requestReview(ReviewPayload reviewPayload) { | |
| } | ||
|
|
||
| private String callChatApi(Map<String, Object> requestBody) { | ||
|
|
||
| OpenAIResponse response = webClient.post() | ||
| .uri("/v1/chat/completions") | ||
| .bodyValue(requestBody) | ||
|
|
@@ -87,14 +87,29 @@ private String callChatApi(Map<String, Object> requestBody) { | |
| .retryWhen( | ||
| Retry.backoff(3, Duration.ofSeconds(1)) | ||
| .maxBackoff(Duration.ofSeconds(5)) | ||
| .filter(ex -> ex instanceof WebClientResponseException | ||
| || ex instanceof TimeoutException) | ||
| .filter(ex -> { | ||
| if (ex instanceof TimeoutException) { | ||
| return true; | ||
| } | ||
| if (ex instanceof WebClientResponseException) { | ||
| HttpStatusCode statusCode = ((WebClientResponseException) ex).getStatusCode(); | ||
| // 5xx 서버 오류만 재시도 (502, 503 등) | ||
| return statusCode.is5xxServerError(); | ||
| } | ||
| return false; | ||
| }) | ||
| .onRetryExhaustedThrow((spec, signal) -> signal.failure()) | ||
| ) | ||
| .onErrorMap(WebClientResponseException.class, | ||
| ex -> new CodeReviewException(CodeReviewExceptionCode.REVIEW_SERVER_ERROR)) | ||
| .onErrorMap(TimeoutException.class, | ||
| ex -> new CodeReviewException(CodeReviewExceptionCode.REVIEW_TIMEOUT)) | ||
| .onErrorMap(WebClientResponseException.class, ex -> { | ||
| HttpStatusCode statusCode = ex.getStatusCode(); | ||
| String responseBody = ex.getResponseBodyAsString(); | ||
| log.error("OpenAI API 호출 실패 - Status: {}, Response Body: {}", statusCode, responseBody, ex); | ||
| return new CodeReviewException(CodeReviewExceptionCode.REVIEW_SERVER_ERROR); | ||
| }) | ||
| .onErrorMap(TimeoutException.class, ex -> { | ||
| log.error("OpenAI API 호출 타임아웃", ex); | ||
| return new CodeReviewException(CodeReviewExceptionCode.REVIEW_TIMEOUT); | ||
| }) | ||
| .block(); | ||
|
Comment on lines
+103
to
113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네트워크 연결 오류 처리 누락
🤖 Prompt for AI Agents |
||
|
|
||
| return Objects.requireNonNull(response).getReviewContent(); | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
동일 이메일 재가입 후 같은 날 탈퇴 시 unique constraint 충돌 가능성
날짜 기반 suffix만 사용하면 같은 날 동일 이메일로 재가입 후 탈퇴하는 경우 unique key 충돌이 발생할 수 있습니다:
user@example.com→ 탈퇴 →user@example.com__deleted_20231220user@example.comuser@example.com__deleted_20231220(충돌!)또한
markAsDeleted()가 중복 호출되면 suffix가 계속 추가됩니다.🔎 UUID 또는 고유 식별자 추가를 권장합니다
public void markAsDeleted() { this.isDeleted = true; - if (this.email != null && !this.email.isBlank()) { + if (this.email != null && !this.email.isBlank() && !this.email.contains("__deleted_")) { String deletedDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); - this.email = this.email + "__deleted_" + deletedDate; + String uniqueSuffix = java.util.UUID.randomUUID().toString().substring(0, 8); + this.email = this.email + "__deleted_" + deletedDate + "_" + uniqueSuffix; } }📝 Committable suggestion
🤖 Prompt for AI Agents