Skip to content

Conversation

@khyojun
Copy link
Member

@khyojun khyojun commented Oct 13, 2025

👩‍💻 Contents

IllegalArgumentException을 CustomSlackException으로 변경

📝 Review Note

📣 Related Issue

✅ 점검사항

  • docker-compose.yml 파일에 마이그레이션 한 API의 포워딩을 변경해줬나요?
  • Spring Secret 값을 수정하거나 추가했다면 Github Secret에서 수정을 해줬나요?
  • Nestjs Secret 값을 수정하거나 추가했다면 Docker-Compose.yml 파일 및 인스턴스 내부의 .env 파일을 수정했나요?

khyojun and others added 4 commits October 11, 2025 16:57
동일한 이모지로 여러 사용자를 호출할 수 있도록 기능을 확장했습니다.

주요 변경사항:
- MakersUserSlackRepository: 사용자별 이모지 조회/삭제 메서드 추가
- MessageContext: 단일 사용자에서 다중 사용자 리스트로 변경
- SlackMessageService: 다중 사용자 멘션 처리 로직 구현
- SlackUtils: 다중 사용자 멘션 포매팅 유틸리티 메서드 추가
- DTO: userSlackId 파라미터 추가로 사용자별 관리 지원

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Slack 패키지 내 예외 처리를 통일하기 위해 CustomSlackException 도입
- IllegalArgumentException을 CustomSlackException으로 전면 교체
- 로그 레벨을 error에서 warn으로 변경하여 적절한 심각도 반영
- 예외 처리 일관성 개선으로 유지보수성 향상

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@khyojun khyojun requested a review from move-hoon October 13, 2025 14:41
@khyojun khyojun self-assigned this Oct 13, 2025
@height
Copy link

height bot commented Oct 13, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@coderabbitai
Copy link

coderabbitai bot commented Oct 13, 2025

Summary by CodeRabbit

  • Refactor
    • 슬랙 연동 전반의 예외를 커스텀 예외로 통일하여 예외 처리 일관성 및 유지보수성 향상
  • Chores
    • 슬랙 이벤트/소켓/메시지 전송 경로의 로그 레벨을 오류에서 경고로 조정하여 불필요한 에러 로그 감소
    • 메시지 전송 실패 시 에러 메시지 정비로 진단 가시성 개선

Walkthrough

Slack 관련 오류 처리 일관화를 위해 CustomSlackException을 신설하고 SlackMessageService 전반에서 IllegalArgumentException을 대체했습니다. Slack 이벤트 리스너 및 소켓 모드 스타터의 예외 로그 레벨을 error에서 warn으로 조정했습니다. sendMention 경로의 예외 캐치 범위를 확장하고 실패 시 CustomSlackException을 던지도록 변경했습니다.

Changes

Cohort / File(s) Summary
예외 클래스 도입
main/src/main/java/org/sopt/makers/crew/main/global/exception/CustomSlackException.java
RuntimeException 확장 CustomSlackException 신규 추가. 기본 생성자와 메시지 생성자 제공.
Slack 서비스 예외 전환 및 처리 보강
main/src/main/java/org/sopt/makers/crew/main/slack/SlackMessageService.java
IllegalArgumentException → CustomSlackException으로 전환(여러 메서드). sendMention 경로 try-catch 확장(CustomSlackException, SlackApiException, IOException). 실패 시 CustomSlackException throw. 경고 레벨 로깅으로 통일.
이벤트 리스너 로깅 레벨 조정
main/src/main/java/org/sopt/makers/crew/main/slack/SlackEventListener.java
예외 로깅 레벨 error → warn으로 변경.
소켓 모드 스타터 로깅 레벨 조정
main/src/main/java/org/sopt/makers/crew/main/slack/SlackSocketModeStarter.java
init/destroy의 예외 로깅 레벨 error → warn으로 변경. 제어 흐름 변화 없음.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller as Service/Controller
  participant SMS as SlackMessageService
  participant Slack as Slack API

  Caller->>SMS: sendMention(request)
  rect rgba(200,230,255,0.3)
    note right of SMS: 메시지 빌드 및 유저/템플릿 해석
    SMS->>SMS: resolveSlackUser()/extractTemplateCd()
    SMS->>Slack: chat.postMessage(payload)
    alt Post 성공
      Slack-->>SMS: ok
      SMS-->>Caller: success
    else Post 실패
      Slack-->>SMS: error
      SMS->>SMS: throw CustomSlackException
      SMS-->>Caller: CustomSlackException 전파
    end
  end

  rect rgba(255,240,200,0.3)
    note over SMS: 예외 처리 (경고 로그)
    Caller->>Caller: 필요시 상위에서 처리
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • move-hoon

Poem

코드밭 흔드는 바람, 경고로 살짝 톤 다운해요 🌬️
예외는 한데 모아, CustomSlackException 가방에 쏙🎒
멘션 쏘고, 실패하면 점프 백—토끼는 침착하게 홉! 🐇
로그는 노란 빛, 에러는 잠시 숨 고르고
슬랙길 정돈 끝, 이제 부드럽게 고고!

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning 이 PR은 슬랙 이모지 고도화(#747) 요구사항인 그룹별 키워드 제거 및 이모지 호출 기능을 전혀 반영하지 않았습니다. 대신 예외 처리 로직 변경과 로그 레벨 조정에만 집중하고 있어 연관성이 부족합니다. 이슈에 기술된 그룹별 키워드 제거 및 이모지 호출 기능을 구현하거나 예외 변경과 로그 작업을 별도의 PR로 분리하세요.
Out of Scope Changes Check ⚠️ Warning PR에 포함된 CustomSlackException 도입과 IllegalArgumentException 대체, 로그 레벨 변경은 슬랙 이모지 고도화 이슈와 관련이 없습니다. 따라서 요구 범위를 벗어난 변경 사항으로 판단됩니다. 관련 없는 예외 처리 및 로깅 변경은 이 PR에서 제거하거나 별도 PR로 분리하여 슬랙 이모지 고도화 작업에 집중할 수 있도록 조정하세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed 이 제목은 프로젝트에서 IllegalArgumentException을 CustomSlackException으로 리팩토링한 핵심 변경 사항을 명확히 드러냅니다. 접두어 refactor를 사용해 변경 목적을 제시하며 불필요한 정보 없이 간결합니다.
Description Check ✅ Passed PR 설명은 변경된 예외 유형을 명확히 언급하며 코드 수정 내용과 일치합니다. 불필요한 세부정보 없이도 관련 작업을 이해할 수 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#747

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@pull-request-size pull-request-size bot added size/M and removed size/L labels Oct 13, 2025
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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
main/src/main/java/org/sopt/makers/crew/main/slack/SlackMessageService.java (1)

63-86: 예외 처리 로직의 심각한 문제: 검증 예외가 숨겨집니다.

현재 구조에서는 resolveSlackUsermessageBuild에서 발생하는 CustomSlackException(검증 오류)을 catch 블록에서 잡아서 경고 로그만 남기고 삼켜버립니다. 이는 다음과 같은 문제를 야기합니다:

  1. 검증 오류가 숨겨짐: 잘못된 이모지나 템플릿 누락 같은 설정 오류가 조용히 실패
  2. 불일치: 다른 메서드들(insertEvent, updateEvent 등)은 CustomSlackException을 던지는데, 이 메서드만 catch해서 삼킴
  3. 디버깅 어려움: warn 레벨 로그로는 근본 원인 파악이 어려움

다음과 같이 수정하여 검증 예외는 전파하고 Slack API 예외만 처리하세요:

 	public void sendMention(MethodsClient client, ReactionAddedEvent event) {
 		String channel = event.getItem().getChannel();
 		String user = event.getUser();
-		try {
 
-			List<MakersUserSlack> slackUser = resolveSlackUser(event);
+		List<MakersUserSlack> slackUser = resolveSlackUser(event);
+		String sendMessage = messageBuild(slackUser, user);
 
-			String sendMessage = messageBuild(slackUser, user);
+		try {
 			ChatPostMessageResponse responses = client.chatPostMessage(r -> r
 				.channel(channel)
 				.text(sendMessage)
 				.threadTs(event.getItem().getTs()));
 
 			if (responses.isOk())
 				log.info("message send success");
 			else {
-				throw new CustomSlackException("ERROR OCCURED");
+				log.error("Failed to send Slack message: {}", responses.getError());
+				throw new CustomSlackException("Failed to send Slack message: " + responses.getError());
 			}
-		} catch (CustomSlackException | SlackApiException | IOException e) {
-			log.warn("now error : {}", e);
-			log.warn("message send failed");
+		} catch (SlackApiException | IOException e) {
+			log.error("Slack API error occurred", e);
+			throw new CustomSlackException("Failed to send Slack message", e);
 		}
 	}

이렇게 하면:

  • 검증 오류는 호출자에게 전파되어 적절히 처리됨
  • Slack API 관련 예외만 catch하여 CustomSlackException으로 래핑
  • 원인 예외(cause)를 보존하여 디버깅 가능
  • error 레벨 로깅으로 중요한 문제 감지 가능
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 724b8ce and fc57e99.

📒 Files selected for processing (4)
  • main/src/main/java/org/sopt/makers/crew/main/global/exception/CustomSlackException.java (1 hunks)
  • main/src/main/java/org/sopt/makers/crew/main/slack/SlackEventListener.java (1 hunks)
  • main/src/main/java/org/sopt/makers/crew/main/slack/SlackMessageService.java (9 hunks)
  • main/src/main/java/org/sopt/makers/crew/main/slack/SlackSocketModeStarter.java (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
main/src/main/java/org/sopt/makers/crew/main/slack/SlackMessageService.java (1)
main/src/main/java/org/sopt/makers/crew/main/global/exception/CustomSlackException.java (1)
  • CustomSlackException (3-11)
⏰ 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). (1)
  • GitHub Check: Build and Test (SpringBoot)
🔇 Additional comments (8)
main/src/main/java/org/sopt/makers/crew/main/slack/SlackEventListener.java (1)

34-36: 로그 레벨 다운그레이드의 적절성을 재검토해 주세요.

Slack 리액션 이벤트 처리 실패를 경고(warn)로 처리하는 것이 적절한지 확인이 필요합니다. 이벤트 처리 실패가 시스템 문제를 나타낼 수 있고, 사용자 경험에 영향을 줄 수 있다면 error 레벨 유지가 더 적절할 수 있습니다.

다음 사항을 고려해 검토해 주세요:

  • 이벤트 처리 실패가 사용자에게 미치는 영향
  • 모니터링/알림 시스템에서 warn vs error의 구분 기준
  • 실패 빈도 및 복구 가능성
main/src/main/java/org/sopt/makers/crew/main/slack/SlackSocketModeStarter.java (1)

51-53: 종료 시 예외 처리는 적절합니다.

애플리케이션 종료 과정에서의 소켓 모드 정리 실패는 warn 레벨이 적절합니다. 이미 예외 정보도 함께 로깅하고 있어 좋습니다.

main/src/main/java/org/sopt/makers/crew/main/slack/SlackMessageService.java (6)

40-40: LGTM!

IllegalArgumentException을 CustomSlackException으로 교체한 것은 명확한 의도를 전달합니다.


49-50: LGTM!

예외 타입 변경이 적절합니다.


58-58: LGTM!

예외 타입 변경이 적절합니다.


93-95: LGTM!

예외 타입 변경이 적절합니다. 검증 오류를 명확히 전달합니다.


102-104: LGTM!

예외 타입 변경이 적절합니다.


114-123: LGTM!

예외 타입 변경이 적절합니다.

@khyojun khyojun merged commit 5db0926 into develop Oct 13, 2025
2 checks passed
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.

슬랙 이모지 고도화

2 participants