Conversation
Collaborator
Author
변경 사항 요약변경 클래스: build.gradle
변경 클래스: settings.gradle
변경 클래스: ReviewController
주요 변경 코드 (diff 기반): // 이전 시그니처 (diff에서 제거된 형태)
public ResponseEntity<Void> githubWebhook(...) {
reviewUseCase.handle(event, deliveryId, sig256, rawBody);
return ResponseEntity.ok().build();
}
// 변경된 시그니처 (추가된 형태)
public Mono<ResponseEntity<Void>> githubWebhook(...) {
return reviewUseCase.handle(event, deliveryId, sig256, rawBody)
.thenReturn(ResponseEntity.accepted().build());
}변경 클래스: reviewbot.review_server.common.client.GitHubClient
주요 변경 코드 (diff 기반): // comment 메서드 변경
public Mono<Void> comment(GitHubCommentDto.IssueCommentRequest req) {
return gitHubApiClient.post()
.uri("/repos/{owner}/{repo}/issues/{issue_number}/comments", req.getOwner(), req.getRepo(), req.getIssueNumber())
.bodyValue(Map.of("body", req.getBody()))
.retrieve()
.toBodilessEntity()
.then()
.doOnError(e -> log.error("PR 코멘트 요청 중 에러 발생 : {}", e.getMessage()));
}
// getPullRequestDiff 메서드 변경
public Mono<String> getPullRequestDiff(GitHubCommentDto.PRDiffRequest req) {
return gitHubApiClient.get()
.uri("/repos/{owner}/{repo}/pulls/{pull_number}", req.getOwner(), req.getRepo(), req.getPrNumber())
.header("Accept", "application/vnd.github.v3.diff")
.retrieve()
.bodyToMono(String.class)
.doOnError(e -> log.error("PR 정보 가져오기 중 에러 발생 : {}", e.getMessage()));
}변경 클래스: reviewbot.review_server.common.client.OpenAiApiClient
주요 변경 코드 (diff 기반): public Mono<String> ask(String input) {
return Mono.fromCallable(() -> {
ResponseCreateParams.Builder params = ResponseCreateParams.builder()
.input(input)
.model(openAIProps.getModel())
.instructions(promptProps.getCommon())
.maxOutputTokens(openAIProps.getMaxToken());
Response response = openAIClient.responses().create(params.build());
return extractOutputText(response)
.orElseThrow(() -> new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "..."));
})
.subscribeOn(Schedulers.boundedElastic());
}
// 유사하게 ask(input, reviewType) 도 Mono<String>으로 변경변경 클래스: reviewbot.review_server.port.in.ReviewUseCase
주요 변경 코드 (diff 기반): // 이전
void handle(String event, String deliveryId, String sig256, byte[] rawBody);
// 변경
Mono<Void> handle(String event, String deliveryId, String sig256, byte[] rawBody);변경: 삭제된 클래스들 (패키지 reviewbot.review_server.serivce)
(각 파일은 diff에 의해 완전 삭제됨 — 상세 내용은 diff 파일 참조) 변경 클래스: reviewbot.review_server.service.DispatchService (신규)
주요 변경 코드 (diff 기반): private final Sinks.Many<WorkItem> sink = Sinks.many().unicast().onBackpressureBuffer();
private record WorkItem(String deliveryId, byte[] rawBody) {}
@PostConstruct
void startWorker() {
sink.asFlux()
.flatMap(this::processItem, CONCURRENCY)
.subscribe();
}
public Mono<Void> dispatchPullRequest(String deliveryId, byte[] rawBody) {
int current = queued.incrementAndGet();
if (current > QUEUE_CAPACITY) {
queued.decrementAndGet();
return Mono.error(new ResponseStatusException(HttpStatus.TOO_MANY_REQUESTS, "..."));
}
Sinks.EmitResult result = sink.tryEmitNext(new WorkItem(deliveryId, rawBody));
if (result.isFailure()) {
queued.decrementAndGet();
return Mono.error(new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "..."));
}
return Mono.empty();
}
private Mono<Void> processItem(WorkItem item) {
return githubService.reviewPullRequest(item.rawBody())
.doOnSuccess(...)
.doOnError(...)
.onErrorResume(ignored -> Mono.empty())
.doFinally(ignored -> queued.decrementAndGet());
}변경 클래스: reviewbot.review_server.service.GithubService (신규)
주요 변경 코드 (diff 기반): public Mono<Void> reviewPullRequest(byte[] rawBody) {
return Mono.fromCallable(() -> objectMapper.readValue(rawBody, PullRequestWebhookDto.class))
.subscribeOn(Schedulers.boundedElastic())
.flatMap(this::handleWebhook);
}
private Mono<Void> handleWebhook(PullRequestWebhookDto dto) {
// Bot/label 체크 후...
return gitHubClient.getPullRequestDiff(diffRequest)
.flatMap(diff -> {
Mono<String> describeAskResult = openAiApiClient.ask(describeInput, ReviewType.DESCRIBE);
Mono<String> reviewAskResult = openAiApiClient.ask(reviewInput, ReviewType.REVIEW);
return Mono.zip(describeAskResult, reviewAskResult)
.flatMap(results -> postComment(..., results.getT1())
.then(postComment(..., results.getT2())));
})
.onErrorResume(error -> {
// 실패시 실패 코멘트 등록 시도
return postFailureComment(context)
.onErrorResume(inner -> Mono.empty());
});
}변경 클래스: reviewbot.review_server.service.ReviewService (신규)
주요 변경 코드 (diff 기반): @Override
public Mono<Void> handle(String event, String deliveryId, String sig256, byte[] rawBody) {
return Mono.fromRunnable(() -> log.info("[{}] webhook handle 시작", deliveryId))
.then(Mono.fromRunnable(() -> verifyService.verifyHMAC(sig256, rawBody)))
.then(Mono.defer(() -> {
if (dispatchService.isDuplicate(deliveryId)) {
log.info("이미 처리된 웹훅번호입니다 : {}", deliveryId);
return Mono.empty();
}
if (!"pull_request".equals(event)) {
log.info("현재 버전은 pr 이외의 버전을 지원하지 않습니다. 현재 버전 : {} ", event);
return Mono.empty();
}
return dispatchService.dispatchPullRequest(deliveryId, rawBody);
}));
}변경 클래스: VerifyService (패키지명 변경)
(참고: 해당 변경은 diff에서 패키지 선언의 변경만 일부 표시됨.) 위 요약은 PR의 diff 파일만을 근거로 작성되었습니다. diff에 포함되지 않은 프로젝트의 다른 파일/설정(예: Spring 설정, 빈 구성, 다른 호출부의 변경 등)에 대한 정보는 없습니다. (필요할 경우 추가 파일 diff를 제공해 주세요.) |
Collaborator
Author
리뷰 평가 결과사전조건 확인
런타임 오류 확인아래 각 이슈는 왜 중요한지, 구체적인 개선 방법, 무시했을 때의 리스크를 포함합니다.
보안 이슈
주요 개선 사항 요약아래는 PR에서 가장 우선적으로 해결해야 할 4가지 이슈입니다. 각 항목은 왜 중요한지, 최소한의 수정 제안(코드 포함), 무시할 경우의 리스크를 제시합니다.
설명은 여기까지입니다. PR 전체적으로 reactive로 전환한 방향은 적절하며 구조도 잘 정리되어 있습니다. 위 4가지는 운영 안정성과 보안 측면에서 시급히 보완되어야 할 항목입니다. |
- 와일드카드 임포트를 개별 임포트로 변경 - 임포트 순서를 ASCII 순으로 정렬 - 어노테이션 순서 통일 (Spring stereotype → Spring 설정 → Lombok) - 불필요한 빈 줄 제거 - 100자 초과 라인 줄바꿈 적용 - 제어문(if, for) 중괄호 추가 - Properties 클래스 어노테이션 순서 통일 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
No description provided.