-
Notifications
You must be signed in to change notification settings - Fork 53
Add Claude Code command for automated bug labeling through MCP JIRA server #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit adds an AI-powered bug labeling system for the networking team: /label-bugs command: - Automatically analyzes and labels JIRA bugs using area_labels.csv mapping - Uses MCP JIRA server by default for efficient data retrieval - Supports --dry-run flag to preview labels without applying them - Supports --api flag to use Python API through network_bugs_overview script as fallback - Implements confidence-based labeling: high (>80%), medium (40-80%), low (<40%) - Auto-applies high-confidence labels, prompts user for medium/low confidence - Detects backports via issue dependencies and applies SDN:Backport label - Skips bugs that already have SDN area labels Additional changes: - Add comprehensive MCP JIRA server configuration instructions to README.md - Document /label-bugs usage and examples in README.md
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ricky-rav The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
WalkthroughIntroduces automated JIRA bug labeling functionality via a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this 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 (5)
jira-scripts/README.md (2)
42-111: Clarify PAT handling and encourage env‑based configurationThe MCP JIRA section is clear and accurate, and the explicit warning about not committing
.claude/settings.jsonis good. To further reduce risk of accidental token leaks, consider either:
- Showing an example that reads
JIRA_PERSONAL_TOKENfrom the user's shell environment (leaving the value empty or as a placeholder in JSON), or- Calling out that the value should be injected via environment (e.g.,
claude mcp addflow) rather than hard‑coding the real token into the JSON checked into a repo.This keeps the workflow the same while nudging users toward safer defaults.
17-27: Address markdownlint warnings for fenced code blocks and bare URLsmarkdownlint is flagging this file for:
- Fenced code blocks without a language, and
- Bare URLs (e.g.,
https://issues.redhat.com, GitHub links).If markdownlint runs in CI, consider:
- Adding a language such as
bash,json, ortextto all new fenced code blocks, and- Wrapping bare URLs in angle brackets (
<https://…>) or link syntax ([link text](https://…)).This should clear the MD034/MD040 warnings noted in the static analysis.
Also applies to: 42-111
jira-scripts/network_bugs_overview (2)
1189-1203: CLI wiring for--query/--label-*looks sound; note mutually exclusive behaviorThe new arguments (
--query,--label-bug,--label) are correctly parsed and threaded throughparams. Inmain(), the subsequent short‑circuiting means:
- If
--queryis provided, onlyrun_custom_queryruns and all other flags are effectively ignored.- If either
--label-bugor--labelis provided, onlyapply_label_to_bugruns (with a runtime check enforcing both are present).This is a reasonable design for ad‑hoc utilities, but it does mean combinations like
--query --jira-bugswon’t behave additively. If that could surprise users, consider documenting this “one special action per run” behavior in the script’s help or README.Also applies to: 1229-1242
1246-1305:run_custom_queryimplementation aligns with docs; consider note on large result sets
run_custom_query:
- Reuses the existing retrying
run_jira_queryhelper.- Prints per‑bug ID, URL, summary, components, labels, issue links, description (truncated to 500 chars), and up to 5 comments.
- Gracefully handles empty results and any failures when reading issue links or comments (they’re best‑effort).
This matches what the
/label-bugsAPI‑mode documentation promises fornetwork_bugs_overview --query. For large JQL result sets, per‑issuejira_client.comments(bug)may be chatty, but that’s acceptable for an on‑demand debugging/AI integration tool. If you start querying hundreds of bugs at once, you might later consider an option to skip comments for performance.jira-scripts/.claude/commands/label-bugs.md (1)
42-51: Tidy fenced code blocks and bare URLs to satisfy markdownlintStatic analysis flags several spots here for:
- Fenced code blocks without a language (
```alone around JQL and output examples).- Bare URLs in example text (e.g.,
https://issues.redhat.com/browse/OCPBUGS-XXXXX).To keep the docs lint‑clean and more readable, consider:
- Adding an explicit language to each fence, e.g.
```bashfor commands,```textor```nonefor plain output/JQL.- Wrapping URLs in angle brackets (
<https://…>) or markdown links.These are purely documentation polish changes and won’t affect the behavior of
/label-bugs, but they’ll clear the MD034/MD040 warnings mentioned in static analysis.Also applies to: 77-90, 93-107, 133-156, 168-171
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
⛔ Files ignored due to path filters (1)
jira-scripts/area_labels.csvis excluded by!**/*.csv
📒 Files selected for processing (3)
jira-scripts/.claude/commands/label-bugs.md(1 hunks)jira-scripts/README.md(2 hunks)jira-scripts/network_bugs_overview(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
jira-scripts/README.mdjira-scripts/network_bugs_overview
🪛 markdownlint-cli2 (0.18.1)
jira-scripts/README.md
42-42: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
68-68: Bare URL used
(MD034, no-bare-urls)
69-69: Bare URL used
(MD034, no-bare-urls)
77-77: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
86-86: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
94-94: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
jira-scripts/.claude/commands/label-bugs.md
42-42: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
68-68: Bare URL used
(MD034, no-bare-urls)
69-69: Bare URL used
(MD034, no-bare-urls)
77-77: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
86-86: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
94-94: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
133-133: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
168-168: Bare URL used
(MD034, no-bare-urls)
🔇 Additional comments (3)
jira-scripts/network_bugs_overview (2)
1307-1337:apply_label_to_bugis safe and idempotent for repeated labelingThe labeling helper:
- Validates that both
bug_idandlabelare provided and prints a clear error otherwise.- Fetches the issue, checks for the label’s presence, and exits early with a friendly message if it already exists.
- Updates the
labelsfield with the new label appended, then prints URL, summary, and the full label list.- Catches and reports any exceptions from the JIRA client.
This fits the
/label-bugsAPI‑mode contract of “apply this one label and report back” and is safe to call repeatedly for the same(bug_id, label)pair. No changes needed here.
1445-1452: Short‑circuit order inmain()is correct for /label-bugs integrationThe execution order in
main():
--print-bug--query--label-bug/--label- recent/old bot utilities
- normal Jira/GitHub processing
ensures
/label-bugs’s API‑mode uses (--query,--label-bug/--label) don’t accidentally trigger the legacy reporting logic. That matches the PR’s goal of exposing ad‑hoc query/label operations without interfering with existing workflows.If you later add more “utility” flags, keeping them in this early‑return block will preserve the same mental model: one special action per invocation.
jira-scripts/.claude/commands/label-bugs.md (1)
7-176: Spec for/label-bugsis consistent with the Python helpers and MCP flowThe document clearly ties together:
- MCP mode using
mcp__jira-atlassian__jira_search/jira_update_issuewith the provided JQL and fields.- API mode using
./network_bugs_overview --query …and--label-bug/--label, which matches the newrun_custom_queryandapply_label_to_bughelpers.- Confidence thresholds, dry‑run behavior (no AskUserQuestion,
[DRY RUN]prefixes), and the requirement to skip bugs that already carry SDN area labels.From an implementation perspective this gives a precise contract for the command and aligns with the script changes in this PR, so it should be straightforward to keep the behavior consistent.
|
@ricky-rav: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
This commit adds an AI-powered bug labeling system for the networking team:
/label-bugs command:
Additional changes:
When retrieving bugs through the MCP JIRA server, it needs ~1000 tokens per bug, even if we ask for only a limited set of fields, because - it seems - the answer will contain all jira fields anyway (empty if not requested, filled out if requested).
So I provided also a way to do the same operation via the standard jira API with the existing python script.
Usage: