Skip to content

Conversation

@ricky-rav
Copy link
Contributor

@ricky-rav ricky-rav commented Nov 26, 2025

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

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:

$ claude
/label-bugs # fetching jira bugs through MCP Jira server & labeling them
/label-bugs --dryrun # as above, but without any labels getting applied on jira
/label-bugs --api # fetching jira bugs through jira API and labeling them also through the API
/label-bugs --api --dry-run # as above, but without any labels getting applied on jira

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
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 26, 2025

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Walkthrough

Introduces automated JIRA bug labeling functionality via a new /label-bugs command, with supporting documentation for the workflow and MCP server configuration. Enhances the network_bugs_overview script with new CLI arguments and functions to support custom queries and label operations on JIRA bugs.

Changes

Cohort / File(s) Summary
Documentation
jira-scripts/.claude/commands/label-bugs.md, jira-scripts/README.md
New command documentation for automated bug labeling workflow specifying usage, operational modes (MCP vs. API), dry-run behavior, label mappings, confidence levels, and user interaction requirements. README expanded with MCP JIRA Server setup section, configuration examples, and token handling guidance for Claude Code integration.
Script enhancement
jira-scripts/network_bugs_overview
Added three CLI arguments (--query, --label-bug, --label) and two new functions (run_custom_query() and apply_label_to_bug()) to support custom JQL queries and dynamic label application to JIRA bugs. Main flow modified to short-circuit to these operations when arguments are provided.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • apply_label_to_bug() function: Verify JIRA API integration, error handling for duplicate labels, input validation, and success/failure reporting
  • run_custom_query() function: Confirm JQL execution, output formatting consistency, and handling of empty result sets
  • Dry-run compliance: Ensure label operations respect dry-run mode constraints and output formatting as documented in label-bugs.md
  • Integration flow: Validate argument precedence (query/label operations exiting before standard processing) and interaction with existing functionality
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

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 (5)
jira-scripts/README.md (2)

42-111: Clarify PAT handling and encourage env‑based configuration

The MCP JIRA section is clear and accurate, and the explicit warning about not committing .claude/settings.json is good. To further reduce risk of accidental token leaks, consider either:

  • Showing an example that reads JIRA_PERSONAL_TOKEN from 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 add flow) 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 URLs

markdownlint 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, or text to 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 behavior

The new arguments (--query, --label-bug, --label) are correctly parsed and threaded through params. In main(), the subsequent short‑circuiting means:

  • If --query is provided, only run_custom_query runs and all other flags are effectively ignored.
  • If either --label-bug or --label is provided, only apply_label_to_bug runs (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-bugs won’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_query implementation aligns with docs; consider note on large result sets

run_custom_query:

  • Reuses the existing retrying run_jira_query helper.
  • 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-bugs API‑mode documentation promises for network_bugs_overview --query. For large JQL result sets, per‑issue jira_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 markdownlint

Static 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. ```bash for commands, ```text or ```none for 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

📥 Commits

Reviewing files that changed from the base of the PR and between b3053c2 and c46bca8.

⛔ Files ignored due to path filters (1)
  • jira-scripts/area_labels.csv is 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.md
  • jira-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_bug is safe and idempotent for repeated labeling

The labeling helper:

  • Validates that both bug_id and label are 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 labels field 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-bugs API‑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 in main() is correct for /label-bugs integration

The execution order in main():

  1. --print-bug
  2. --query
  3. --label-bug/--label
  4. recent/old bot utilities
  5. 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-bugs is consistent with the Python helpers and MCP flow

The document clearly ties together:

  • MCP mode using mcp__jira-atlassian__jira_search/jira_update_issue with the provided JQL and fields.
  • API mode using ./network_bugs_overview --query … and --label-bug/--label, which matches the new run_custom_query and apply_label_to_bug helpers.
  • 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.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 26, 2025

@ricky-rav: all tests passed!

Full PR test history. Your PR dashboard.

Details

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant