Skip to content

[FEAT] 유저가 임의로 웹훅 삭제 시, 트래킹을 끊는 로직 작성#73

Merged
coli-geonwoo merged 4 commits intodevelopfrom
feat/#71-delete-repository-when-nonexists-webhook
Aug 7, 2025
Merged

[FEAT] 유저가 임의로 웹훅 삭제 시, 트래킹을 끊는 로직 작성#73
coli-geonwoo merged 4 commits intodevelopfrom
feat/#71-delete-repository-when-nonexists-webhook

Conversation

@coli-geonwoo
Copy link
Collaborator

@coli-geonwoo coli-geonwoo commented Aug 5, 2025

🚩 연관 JIRA 이슈

jira issue url:

유저가 임의로 웹훅을 삭제했다면 GithubNotFoundException이 발생하여 트래킹을 끊는 작업이 불가합니다.
이에 웹훅을 찾지 못하더라도 repo의 상태를 isTracking=false로 바꿀 수 있도록 수정합니다.

🔂 변경 내역

🗣️ 리뷰 요구사항 (선택)

Summary by CodeRabbit

  • 버그 수정

    • GitHub 웹훅 삭제 시 웹훅이 존재하지 않아도 오류를 적절히 처리하도록 개선되었습니다.
  • 테스트

    • 웹훅이 존재하지 않아도 레포지토리 트래킹이 정상적으로 중단되는지 확인하는 테스트가 추가되었습니다.
  • 신규 기능

    • GitHub 리소스를 찾을 수 없을 때를 위한 전용 예외가 도입되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 5, 2025

Walkthrough

GitHub 웹훅 삭제 시 발생할 수 있는 예외를 처리하도록 서비스 로직이 개선되었으며, 404 오류에 대해 새로운 GithubNotFoundException을 사용하도록 클라이언트 예외 처리도 변경되었습니다. 이에 대한 단위 테스트와 새로운 예외 클래스가 추가되었습니다.

Changes

Cohort / File(s) Change Summary
GitHubService 예외 처리 및 로깅 개선
gss-api-app/src/main/java/com/devoops/service/GitHubService.java
웹훅 삭제 시 예외 처리 로직 추가, GithubNotFoundException 발생 시 로그 기록 및 예외 전파 방지, @Slf4j 어노테이션 추가
RepositoryFacadeService 테스트 추가
gss-api-app/src/test/java/com/devoops/service/facade/RepositoryFacadeServiceTest.java
웹훅 삭제 시 404 예외가 발생해도 레포지토리 트래킹이 정상적으로 해제되는지 검증하는 테스트 클래스 및 메서드 추가
404 예외 처리 방식 변경
gss-client/gss-github-client/src/main/java/com/devoops/client/GithubExchangeFilterFunction.java
404 상태 코드 발생 시 기존의 일반 예외 대신 GithubNotFoundException을 던지도록 변경
GithubNotFoundException 도입
gss-client/gss-github-client/src/main/java/com/devoops/exception/GithubNotFoundException.java
GithubNotFoundException 커스텀 런타임 예외 클래스 신규 추가

Sequence Diagram(s)

sequenceDiagram
    participant Service as GitHubService
    participant Client as gitHubClient
    participant Logger as slf4j

    Service->>Client: deleteWebhook(token, webhook, repo)
    alt 정상 삭제
        Client-->>Service: 성공
    else GithubNotFoundException 발생
        Client-->>Service: 예외 발생
        Service->>Logger: error("웹훅을 찾을 수 없음", 예외, repo)
        Service-->>Service: 예외 무시하고 계속 진행
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

refactor, fix

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#71-delete-repository-when-nonexists-webhook

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Aug 5, 2025

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 6d04d99.

@github-actions
Copy link

github-actions bot commented Aug 5, 2025

📝 Test Coverage Report

Overall Project NaN% NaN% 🍏

There is no coverage information present for the Files changed

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
gss-client/gss-github-client/src/main/java/com/devoops/exception/GithubNotFoundException.java (1)

3-7: 직렬화 호환성을 위해 serialVersionUID 추가를 고려해주세요.

RuntimeException을 상속하는 예외 클래스는 Serializable을 구현하므로, 직렬화 호환성을 위해 serialVersionUID를 명시적으로 선언하는 것이 좋습니다.

 public class GithubNotFoundException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+    
     public GithubNotFoundException(String message) {
         super(message);
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between feccdcd and 6d04d99.

📒 Files selected for processing (4)
  • gss-api-app/src/main/java/com/devoops/service/GitHubService.java (2 hunks)
  • gss-api-app/src/test/java/com/devoops/service/facade/RepositoryFacadeServiceTest.java (3 hunks)
  • gss-client/gss-github-client/src/main/java/com/devoops/client/GithubExchangeFilterFunction.java (2 hunks)
  • gss-client/gss-github-client/src/main/java/com/devoops/exception/GithubNotFoundException.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: in this codebase, equals and hashcode methods (including lombok's @EqualsAndHashCode annotation) are...
Learnt from: coli-geonwoo
PR: mash-up-kr/GSS-Server#16
File: gss-domain/src/main/java/com/devoops/domain/entity/github/Question.java:6-12
Timestamp: 2025-06-09T14:20:16.095Z
Learning: In this codebase, equals and hashCode methods (including Lombok's @EqualsAndHashCode annotation) are prohibited by team coding convention and should not be suggested in code reviews.

Applied to files:

  • gss-api-app/src/test/java/com/devoops/service/facade/RepositoryFacadeServiceTest.java
🧬 Code Graph Analysis (1)
gss-client/gss-github-client/src/main/java/com/devoops/client/GithubExchangeFilterFunction.java (1)
gss-client/gss-github-client/src/main/java/com/devoops/exception/GithubNotFoundException.java (1)
  • GithubNotFoundException (3-7)
🔇 Additional comments (16)
gss-client/gss-github-client/src/main/java/com/devoops/client/GithubExchangeFilterFunction.java (4)

3-3: LGTM!

새로운 GithubNotFoundException import가 올바르게 추가되었습니다.


30-32: GitHub 404 에러에 대한 특화된 예외 처리로 개선되었습니다.

기존의 일반적인 GssException 대신 GithubNotFoundException을 사용하여 GitHub 리소스를 찾을 수 없는 경우를 더 명확하게 구분할 수 있게 되었습니다. 이는 상위 레이어에서 해당 예외를 적절히 처리할 수 있도록 도와줍니다.


3-3: 새로운 예외 클래스 import가 추가되었습니다.

GithubNotFoundException을 사용하기 위한 import 구문이 적절히 추가되었습니다.


31-31: 404 오류에 대한 더 구체적인 예외 처리로 개선되었습니다.

기존의 일반적인 GssException 대신 GithubNotFoundException을 사용하여 404 오류를 더 명확하게 처리할 수 있게 되었습니다. 이를 통해 서비스 레이어에서 GitHub 리소스를 찾을 수 없는 경우를 구분하여 처리할 수 있습니다.

gss-api-app/src/test/java/com/devoops/service/facade/RepositoryFacadeServiceTest.java (4)

7-7: LGTM!

필요한 import 문들이 올바르게 추가되었습니다.

Also applies to: 20-20


84-101: 웹훅 삭제 실패 시나리오에 대한 테스트가 잘 구현되었습니다.

이 테스트는 PR의 핵심 요구사항을 정확히 검증합니다:

  • 웹훅 삭제 시 GithubNotFoundException이 발생해도
  • 레포지토리의 트래킹 상태는 여전히 false로 설정되는지 확인

mocking과 assertion이 적절하게 구현되어 있고, 기존 테스트 패턴과 일관성을 유지하고 있습니다.


20-20: 새로운 예외 클래스에 대한 import가 추가되었습니다.

테스트에서 GithubNotFoundException을 사용하기 위한 import 구문이 적절히 추가되었습니다.


84-101: 웹훅 삭제 실패 시나리오에 대한 테스트가 잘 작성되었습니다.

GitHub에서 웹훅을 찾을 수 없는 상황에서도 레포지토리 트래킹을 정상적으로 비활성화할 수 있는지 검증하는 테스트가 적절히 구현되었습니다.

  • 명확한 테스트 메서드명으로 테스트 의도가 잘 드러남
  • 적절한 목킹을 통해 예외 상황을 재현
  • 예상되는 동작(isTracking = false)을 정확히 검증
gss-api-app/src/main/java/com/devoops/service/GitHubService.java (7)

16-16: LGTM!

필요한 import와 @slf4j 어노테이션이 올바르게 추가되었습니다.

Also applies to: 21-21, 26-26


96-98: 웹훅 삭제 로직이 안전하게 분리되었습니다.

tryDeleteWebhook 메서드로 위험한 작업을 분리하여, 웹훅 삭제가 실패하더라도 데이터베이스에서는 여전히 웹훅 레코드가 삭제되도록 구현되었습니다.


100-111: isTracking 상태 갱신 로직 확인 필요
GitHubNotFoundException 처리(로그만 남기고 예외 전파하지 않음)는 PR 요구사항에 맞게 구현되었습니다. 다만, 웹훅 삭제 이후 GithubRepository#isTracking 필드를 false로 설정하는 로직이 코드베이스에서 확인되지 않습니다. 삭제 처리 흐름에서 트래킹 중단이 정상적으로 수행되는지 아래 항목을 점검해주세요.

  • deleteRepository 메서드 구현부에서 isTracking = false 또는 setTracking(false) 호출 여부
  • 별도의 updateRepository, stopTracking 등 서비스 레이어 메서드 확인
  • JPA 엔티티 변경 혹은 CQRS 핸들러 등 데이터 변경 로직 내 상태 변경 누락 여부

16-16: 새로운 예외 클래스에 대한 import가 추가되었습니다.

GithubNotFoundException을 처리하기 위한 import 구문이 적절히 추가되었습니다.


21-21: 로깅을 위한 Slf4j 설정이 추가되었습니다.

웹훅 삭제 실패 시 로깅을 위해 @slf4j 어노테이션과 import가 적절히 추가되었습니다.

Also applies to: 26-26


96-96: 웹훅 삭제 로직이 안전한 방식으로 분리되었습니다.

기존의 직접적인 웹훅 삭제 호출을 tryDeleteWebhook 메서드로 분리하여 예외 처리를 할 수 있도록 개선되었습니다.


100-111: 웹훅 삭제 실패에 대한 안전한 예외 처리가 구현되었습니다.

GitHub에서 웹훅을 찾을 수 없는 경우에도 트래킹을 중단할 수 있도록 하는 핵심 로직이 잘 구현되었습니다.

  • GithubNotFoundException을 명시적으로 캐치하여 예외 전파를 방지
  • 디버깅을 위한 충분한 로그 정보 제공 (예외 정보 + 레포지토리 이름)
  • 메서드명이 의도를 명확하게 표현 (tryDeleteWebhook)

이를 통해 사용자가 수동으로 웹훅을 삭제한 경우에도 시스템에서 정상적으로 트래킹을 종료할 수 있게 되었습니다.

gss-client/gss-github-client/src/main/java/com/devoops/exception/GithubNotFoundException.java (1)

3-6: 깔끔한 예외 클래스 구현입니다.

GitHub 404 오류를 명확하게 표현하는 커스텀 예외 클래스가 적절하게 구현되었습니다. RuntimeException을 상속받아 언체크 예외로 설계한 것이 올바릅니다.

@coli-geonwoo coli-geonwoo merged commit 8bb5bd3 into develop Aug 7, 2025
5 checks passed
@coli-geonwoo coli-geonwoo deleted the feat/#71-delete-repository-when-nonexists-webhook branch August 7, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 웹훅이 없을 때에도 정상적으로 삭제되도록 수정

1 participant