fix(issue-labels): reduce mislabeling and handle missing labels#288
Conversation
Make type classification more conservative to avoid incorrect labels, and avoid skipping entire issues when some managed labels are missing.
Add labeled/unlabeled issue examples to cover question/bug/enhancement and domain inference.
Keep one sample per source_url to reduce confusion and maintain stable regression coverage.
📝 WalkthroughWalkthroughReplaced simple keyword checks with a weighted, regex-rule scoring classifier for issue types and added conservative decision thresholds. Title heuristics adjusted. Label-application now filters missing repository labels instead of skipping the issue. Samples dataset updated and expanded. Changes
Sequence Diagram(s)sequenceDiagram
participant Runner as Issue-Labeler Script
participant Scorer as Scoring Engine
participant RepoAPI as Repository (labels & issues)
participant Output as JSON/Logs
Runner->>Scorer: parse title/body -> compute weighted scores
Scorer-->>Runner: scores per type
Runner->>Scorer: chooseTypeFromScores(scores, TYPE_MIN_*)
Scorer-->>Runner: chosenType or null
Runner->>RepoAPI: fetch existing labels
RepoAPI-->>Runner: availableLabels
Runner->>Runner: compute toAdd/toRemove (filter missing toAdd)
Runner->>RepoAPI: apply add/remove label operations
RepoAPI-->>Runner: apply results
Runner->>Output: log missing labels, record changes (JSON mode)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@0c3b6b0d6d195a045cb3ce2fe242fe28dcf29dd2🧩 Skill updatenpx skills add fengzhangchi-bytedance/larksuite-cli-fork#fix/issue-labeler-reduce-mislabels -y -g |
Greptile SummaryThis PR makes the issue type classifier more conservative by requiring a minimum score of 2 and a margin of 1 between the top two candidates before applying a type label (preferring
Confidence Score: 5/5Safe to merge; all remaining findings are non-blocking P2 style issues The core logic changes are sound — minimum-score and minimum-margin guards reduce mislabeling, and the partial missing-label fallback correctly applies whichever labels are available. Two P2 issues (dead tie-breaker code and missing JSON metadata in --process-all mode) do not affect correctness on the default usage path. scripts/issue-labels/index.js: dead tie-breaker branches (lines 327–332) and --process-all JSON metadata gap (lines 831–866) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Issue from searchUnlabeledIssues] --> B[classifyIssueText]
B --> C[scoreTypeFromText]
C --> D[chooseTypeFromScores]
D -- score < MIN_SCORE=2 --> E[type = null]
D -- margin < MIN_MARGIN=1 --> E
D -- clear winner --> F[type = winner]
B --> G[collectDomainsFromText]
F --> H[planIssueLabelChanges]
G --> H
E --> H
H --> I{managed labels\nmissing from repo?}
I -- yes --> J[effectiveToAdd = toAdd minus missing]
I -- no --> K[effectiveToAdd = toAdd]
J --> L{hasChange?}
K --> L
L -- no AND onlyMissing\nAND json AND missingForIssue --> M[emit skipped record\nwith reason + missingLabels]
L -- no AND onlyMissing --> N[continue silently]
L -- yes --> O[build record, apply labels]
O --> P{dryRun?}
P -- no --> Q[addIssueLabels + removeIssueLabel]
P -- yes --> R[skip API calls]
Greploops — Automatically fix all review issues by running Reviews (2): Last reviewed commit: "fix(issue-labels): include missing-label..." | Re-trigger Greptile |
Keep stderr and JSON output consistent under --only-missing when desired labels are missing from the repo.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
scripts/issue-labels/index.js (1)
809-829:⚠️ Potential issue | 🟡 Minor
skippedIssuecounter not incremented when--jsonis false.When
args.jsonis false, issues skipped due to missing managed labels are not counted inresults.skippedIssue. The warning is logged at Line 803, but the final summary at Line 872 will undercount skipped issues.🐛 Proposed fix
if (args.onlyMissing && !hasChange) { + if (missingForIssue.length > 0) { + results.skippedIssue += 1; + } if (args.json && missingForIssue.length > 0) { - results.skippedIssue += 1; results.changes.push({ issue: { number: issue.number,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/issue-labels/index.js` around lines 809 - 829, The skippedIssue counter isn't incremented when args.onlyMissing && !hasChange and args.json is false; update the block handling that condition (the if branch checking args.onlyMissing && !hasChange) to always increment results.skippedIssue for skipped issues regardless of args.json, then keep the existing results.changes.push(...) behavior only when args.json is true and missingForIssue.length > 0; touch the symbols args.onlyMissing, hasChange, args.json, missingForIssue, and results.skippedIssue to ensure skipped counts are correct in both JSON and non-JSON runs.
🧹 Nitpick comments (1)
scripts/issue-labels/index.js (1)
797-799: Minor: Redundant conditional wrapping the filter.The ternary check
missingForIssue.length > 0is unnecessary since the filter expression!missingManagedLabels.has(name)would returntoAddunchanged when there are no missing labels.♻️ Suggested simplification
- const effectiveToAdd = missingForIssue.length > 0 - ? toAdd.filter((name) => !missingManagedLabels.has(name)) - : toAdd; + const effectiveToAdd = toAdd.filter((name) => !missingManagedLabels.has(name));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/issue-labels/index.js` around lines 797 - 799, Replace the redundant ternary assigning effectiveToAdd: instead of checking missingForIssue.length > 0, always compute effectiveToAdd by filtering toAdd with the predicate !missingManagedLabels.has(name); this removes the unnecessary conditional and yields the same result (use the variables effectiveToAdd, toAdd, missingManagedLabels, and missingForIssue from the current code to locate the change).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@scripts/issue-labels/index.js`:
- Around line 809-829: The skippedIssue counter isn't incremented when
args.onlyMissing && !hasChange and args.json is false; update the block handling
that condition (the if branch checking args.onlyMissing && !hasChange) to always
increment results.skippedIssue for skipped issues regardless of args.json, then
keep the existing results.changes.push(...) behavior only when args.json is true
and missingForIssue.length > 0; touch the symbols args.onlyMissing, hasChange,
args.json, missingForIssue, and results.skippedIssue to ensure skipped counts
are correct in both JSON and non-JSON runs.
---
Nitpick comments:
In `@scripts/issue-labels/index.js`:
- Around line 797-799: Replace the redundant ternary assigning effectiveToAdd:
instead of checking missingForIssue.length > 0, always compute effectiveToAdd by
filtering toAdd with the predicate !missingManagedLabels.has(name); this removes
the unnecessary conditional and yields the same result (use the variables
effectiveToAdd, toAdd, missingManagedLabels, and missingForIssue from the
current code to locate the change).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 626f7826-cc48-4bd5-b383-9535bb25ff87
📒 Files selected for processing (1)
scripts/issue-labels/index.js
Summary
Make the issue labeler more conservative to reduce mislabeling, and avoid skipping entire issues when some managed labels are missing in the repo.
Changes
Test Plan
node scripts/issue-labels/test.js
Summary by CodeRabbit
Bug Fixes
Tests