Skip to content

Conversation

@move-hoon
Copy link
Member

@move-hoon move-hoon commented Apr 25, 2025

Related issue 🛠

Work Description ✏️

image
  • Slack의 header block 텍스트 길이 제한(150자)을 초과하면 invalid_attachments 에러가 발생하는 문제를 수정했습니다.
  • 메시지 앞에 붙는 이모지(🚨)와 말줄임표(...)까지 고려하여 최대 허용 길이 내에서 잘라내고 말줄임표를 붙이는 방식으로 처리했습니다.

Trouble Shooting ⚽️

  • None

@height
Copy link

height bot commented Apr 25, 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 Apr 25, 2025

Summary by CodeRabbit

  • New Features

    • 슬랙 메시지 헤더에 이모지 프리픽스가 추가되고, 최대 길이 초과 시 자동으로 말줄임표가 붙는 기능이 적용되었습니다.
  • Documentation

    • README의 프로젝트 동기 및 배경 설명이 더욱 명확하고 상세하게 개선되었습니다.
      """

Summary by CodeRabbit

  • 신규 기능
    • 슬랙 메시지 헤더에 🚨 이모지 프리픽스가 자동으로 추가됩니다.
    • 헤더 길이가 제한을 초과할 경우 자동으로 말줄임표(...)로 표시됩니다.

Walkthrough

이 변경사항은 Slack 알림의 헤더 메시지 길이 제한을 처리하기 위해 새로운 상수를 추가하고, 헤더 메시지 생성 로직을 수정합니다. SlackConstant 클래스에 헤더 관련 상수(최대 길이, 이모지 접두사, 생략 표시)를 추가했으며, SlackNotificationService에서 헤더 메시지 길이와 이모지 접두사를 고려하여 메시지를 자르고 생략 표시를 붙이도록 변경했습니다. 또한, HeaderBlock에서는 더 이상 이모지 접두사를 추가하지 않고 전달받은 텍스트를 그대로 사용합니다.

Changes

파일/경로 요약 변경 요약
src/main/java/org/sopt/makers/global/constant/SlackConstant.java 헤더 관련 상수(MAX_HEADER_LENGTH, EMOJI_PREFIX, TRUNCATION_SUFFIX) 추가
src/main/java/org/sopt/makers/service/SlackNotificationService.java 헤더 메시지에 이모지 접두사 추가, 최대 길이 초과 시 메시지 자르고 생략 표시 붙이도록 로직 수정
src/main/java/org/sopt/makers/vo/slack/block/HeaderBlock.java 헤더 생성 시 이모지 접두사 제거, 입력받은 텍스트 그대로 사용하도록 변경

Sequence Diagram(s)

sequenceDiagram
    participant SlackNotificationService
    participant SlackConstant
    participant HeaderBlock

    SlackNotificationService->>SlackConstant: Get EMOJI_PREFIX, MAX_HEADER_LENGTH, TRUNCATION_SUFFIX
    SlackNotificationService->>SlackNotificationService: 메시지 길이와 접두사 고려하여 자르기/생략 표시 추가
    SlackNotificationService->>HeaderBlock: newInstance(최종 메시지)
    HeaderBlock->>HeaderBlock: PlainText.newInstance(메시지)
Loading

Assessment against linked issues

Objective Addressed Explanation
header 블록의 텍스트가 150자를 초과할 경우, 최대 길이인 150자까지만 잘라서 전송하도록 처리 (#17)

Possibly related PRs

Poem

🐰
슬랙에 알림이 똑똑,
헤더 길이 딱 맞춰서 똑똑!
이모지와 점 세 개,
너무 길면 살짝 잘라내.
이제 오류 없이 쏙쏙,
토끼도 안심하고 뛴다,
코드는 오늘도 똑똑!
🚨...
"""


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d0656f8 and dc00fa6.

📒 Files selected for processing (1)
  • README.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • README.md

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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.

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)
src/main/java/org/sopt/makers/service/SlackNotificationService.java (1)

112-120: 메시지 길이 제한 처리 로직이 잘 구현되었습니다.

SlackConstant에 정의된 상수들을 활용하여 헤더 메시지의 길이를 적절히 제한하고, 이모지 접두사와 생략 표시를 일관되게 처리하는 로직이 잘 구현되었습니다. 다만, 아래와 같은 개선 사항을 고려해 볼 수 있습니다:

  1. 메시지가 null인 경우에 대한 방어 코드 추가
  2. 문자열 연산 대신 StringBuilder 사용 고려 (성능 최적화)

아래와 같이 리팩토링할 수 있습니다:

private Block buildHeaderBlock(String message) {
+   if (message == null) {
+       message = "";
+   }
    
    String fullMessage = EMOJI_PREFIX + message;

    if (fullMessage.length() > MAX_HEADER_LENGTH) {
        int maxLength = MAX_HEADER_LENGTH - EMOJI_PREFIX.length() - TRUNCATION_SUFFIX.length();
        fullMessage = EMOJI_PREFIX + message.substring(0, maxLength) + TRUNCATION_SUFFIX;
    }

    return HeaderBlock.newInstance(fullMessage);
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ae9bea1 and d0656f8.

📒 Files selected for processing (3)
  • src/main/java/org/sopt/makers/global/constant/SlackConstant.java (1 hunks)
  • src/main/java/org/sopt/makers/service/SlackNotificationService.java (1 hunks)
  • src/main/java/org/sopt/makers/vo/slack/block/HeaderBlock.java (1 hunks)
🔇 Additional comments (2)
src/main/java/org/sopt/makers/global/constant/SlackConstant.java (1)

44-47: 상수 추가가 적절하게 되었습니다!

헤더 관련 상수들을 추가하여 코드의 가독성과 유지보수성이 향상되었습니다. MAX_HEADER_LENGTH, EMOJI_PREFIX, TRUNCATION_SUFFIX 상수를 통해 메시지 길이 제한 및 형식이 일관되게 적용될 수 있습니다.

src/main/java/org/sopt/makers/vo/slack/block/HeaderBlock.java (1)

13-13: 관심사 분리가 잘 이루어졌습니다.

이모지 접두사를 HeaderBlock 내부에서 처리하는 대신 외부(SlackNotificationService)에서 처리하도록 변경한 점이 좋습니다. 이를 통해 HeaderBlock은 단순히 텍스트를 표시하는 역할에 집중할 수 있게 되었습니다.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 25, 2025
@move-hoon move-hoon changed the title fix: fix: Slack 알림 헤더가 150자 초과될 경우 말줄임표(...)로 잘라서 전송되도록 수정 Apr 25, 2025
@move-hoon move-hoon merged commit 445fc05 into main Apr 25, 2025
2 checks passed
@move-hoon move-hoon deleted the bug/#17 branch May 12, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: header 블록 텍스트 길이 제한을 넘어서서 메시지가 보내지지 않는 문제

2 participants