[Chore] 이슈 본문에 맞춰 라벨링 자동화#178
Conversation
📝 WalkthroughWalkthroughIssue templates now use normalized labels, ChangesIssue labeling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Issue
participant GitHubActions
participant issue-auto-label.js
participant GitHubIssuesAPI
Issue->>GitHubActions: opened, edited, or reopened event
GitHubActions->>issue-auto-label.js: execute with issue context
issue-auto-label.js->>issue-auto-label.js: parse issue-form values
issue-auto-label.js->>GitHubIssuesAPI: add or remove managed labels
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/issue-auto-label.yml (1)
19-20: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueSet
persist-credentials: falsein the checkout step.To follow security best practices and prevent the GitHub token from persisting in the
.git/configof the runner environment, setpersist-credentials: falsesince this workflow does not need to push changes back to the repository.🔒️ Proposed fix
- name: Checkout labeling script uses: actions/checkout@v5 + with: + persist-credentials: false🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/issue-auto-label.yml around lines 19 - 20, Update the “Checkout labeling script” actions/checkout step to set persist-credentials to false, preventing the GitHub token from being stored in the runner’s Git configuration while preserving the existing checkout behavior.Source: Linters/SAST tools
label.sh (1)
4-8: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove commented-out code.
Dead code should be removed to keep the script clean and maintainable. The version control system retains the history if it's ever needed again.
♻️ Proposed fix
-#labels=(bug documentation duplicate enhancement "good first issue" "help wanted" invalid question wontfix) -# -#for label in "${labels[@]}"; do -# gh label delete "$label" --yes 2>/dev/null -#done🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@label.sh` around lines 4 - 8, Remove the commented-out labels array and deletion loop from label.sh, leaving only active script content and preserving any intended executable behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/scripts/issue-auto-label.js:
- Around line 10-19: Update readIssueFormValue so the optional match capture is
also safely chained before calling trim, returning undefined when the heading or
value is absent instead of throwing a TypeError.
---
Nitpick comments:
In @.github/workflows/issue-auto-label.yml:
- Around line 19-20: Update the “Checkout labeling script” actions/checkout step
to set persist-credentials to false, preventing the GitHub token from being
stored in the runner’s Git configuration while preserving the existing checkout
behavior.
In `@label.sh`:
- Around line 4-8: Remove the commented-out labels array and deletion loop from
label.sh, leaving only active script content and preserving any intended
executable behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ed3cb4b8-447d-4f65-8c87-5491956d3883
📒 Files selected for processing (9)
.github/ISSUE_TEMPLATE/bug.yml.github/ISSUE_TEMPLATE/chore.yml.github/ISSUE_TEMPLATE/deploy.yml.github/ISSUE_TEMPLATE/docs.yml.github/ISSUE_TEMPLATE/feature.yml.github/ISSUE_TEMPLATE/refactor.yml.github/scripts/issue-auto-label.js.github/workflows/issue-auto-label.ymllabel.sh
| function readIssueFormValue(body, heading) { | ||
| const pattern = new RegExp( | ||
| `^###[ \\t]+${escapeRegExp(heading)}[ \\t]*\\r?\\n` + | ||
| `(?:[ \\t]*\\r?\\n)*([^\\r\\n]+)`, | ||
| 'm', | ||
| ); | ||
| const match = body.match(pattern); | ||
|
|
||
| return match?.[1].trim(); | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Prevent TypeError when the issue body does not contain the heading.
If the issue body doesn't match the expected pattern (e.g., if a user deletes the headings or submits a blank issue), match will be null. The expression match?.[1] will evaluate to undefined, and calling .trim() on it will throw a TypeError, causing the GitHub Action to crash.
Use optional chaining before .trim() to safely handle missing matches.
🩹 Proposed fix
function readIssueFormValue(body, heading) {
const pattern = new RegExp(
`^###[ \\t]+${escapeRegExp(heading)}[ \\t]*\\r?\\n` +
`(?:[ \\t]*\\r?\\n)*([^\\r\\n]+)`,
'm',
);
const match = body.match(pattern);
- return match?.[1].trim();
+ return match?.[1]?.trim();
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function readIssueFormValue(body, heading) { | |
| const pattern = new RegExp( | |
| `^###[ \\t]+${escapeRegExp(heading)}[ \\t]*\\r?\\n` + | |
| `(?:[ \\t]*\\r?\\n)*([^\\r\\n]+)`, | |
| 'm', | |
| ); | |
| const match = body.match(pattern); | |
| return match?.[1].trim(); | |
| } | |
| function readIssueFormValue(body, heading) { | |
| const pattern = new RegExp( | |
| `^###[ \\t]+${escapeRegExp(heading)}[ \\t]*\\r?\\n` + | |
| `(?:[ \\t]*\\r?\\n)*([^\\r\\n]+)`, | |
| 'm', | |
| ); | |
| const match = body.match(pattern); | |
| return match?.[1]?.trim(); | |
| } |
🧰 Tools
🪛 ast-grep (0.44.1)
[warning] 10-14: Detects non-literal values in regular expressions
Context: new RegExp(
^###[ \\t]+${escapeRegExp(heading)}[ \\t]*\\r?\\n +
(?:[ \\t]*\\r?\\n)*([^\\r\\n]+),
'm',
)
Note: [CWE-1333] Inefficient Regular Expression Complexity (ReDoS via non-literal RegExp).
(detect-non-literal-regexp)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/scripts/issue-auto-label.js around lines 10 - 19, Update
readIssueFormValue so the optional match capture is also safely chained before
calling trim, returning undefined when the heading or value is absent instead of
throwing a TypeError.
Developer-Choi-Jae-Young
left a comment
There was a problem hiding this comment.
고생하셨습니다.
PR 타입(하나 이상의 PR 타입을 선택해주세요)
변경 사항
처리 시기선택값에 따라P0~P3라벨이 적용되도록 구성했습니다.중요도선택값에 따라Critical~Low라벨이 적용되도록 구성했습니다.label.sh에 처리 시기 및 중요도 라벨 초기화 설정을 추가했습니다.테스트 결과
label.sh셸 문법 검사를 통과했습니다.Summary by CodeRabbit
New Features
Improvements