Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Generating Synthetic Code Review Comments from Bug Fix Histories#5037

Open
leusonmario wants to merge 3 commits into
mozilla:master from
leusonmario:master
Open

Generating Synthetic Code Review Comments from Bug Fix Histories #5037
leusonmario wants to merge 3 commits into
mozilla:master from
leusonmario:master

Conversation

@leusonmario

@leusonmario leusonmario commented May 21, 2025

Copy link
Copy Markdown

Goal: Automatically generate synthetic code review comments by leveraging historical bug reports and their corresponding fixes.
Input: A list of previously reported bugs along with their associated fix implementations (commits).

marco-c commented Jun 4, 2025

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Member

The diff was difficult to review because it included 84 commits from the upstream. I cleaned up the branch and rebased it.

Comment on lines +42 to +76
You are an expert reviewer for source code with extensive experience in analyzing and summarizing code changes.

The bug associated with patch_bug was introduced and later fixed. Below, you can find further information about the fix.
Fix title: {fix_title}
Fix description: {fix_description}

Your task:
Analyze the provided code and generate a concise summary focusing on the exact changes in patch_bug that introduced the issue and how patch_fix resolved it. Ignore any modifications unrelated to the bug fix.

You must report:
1. The root cause of the issue in `patch_bug`: Identify the specific code lines in patch_bug responsible for the bug. Report the exact affected line and explain why they led to the issue. One single line number for change.
2. The specific changes in `patch_fix` that correct the issue: Explain how the bug was resolved, but keep the focus on mapping fixes back to the faulty lines in `patch_bug`.

Output Format:
Provide a structured response that explicitly maps faulty lines in `patch_bug` to the fix in `patch_fix`, like this:

{{
"root_cause": {{
"filename": "<file_path>",
"line": [<line_number>],
"explanation": "<Why these lines introduced the bug>"
}},
"fix": {{
"filename": "<file_path>",
"line": [<line_number>],
"explanation": "<How these changes in patch_fix resolved the issue>"
}}
}}

Bug commit message: {bug_commit_message}
{patch_bug}

Fix commit message: {fix_commit_message}
{patch_fix}
"""

@suhaibmujahid suhaibmujahid Jul 9, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need to indent the whole prompt.

Suggested change
You are an expert reviewer for source code with extensive experience in analyzing and summarizing code changes.
The bug associated with patch_bug was introduced and later fixed. Below, you can find further information about the fix.
Fix title: {fix_title}
Fix description: {fix_description}
Your task:
Analyze the provided code and generate a concise summary focusing on the exact changes in patch_bug that introduced the issue and how patch_fix resolved it. Ignore any modifications unrelated to the bug fix.
You must report:
1. The root cause of the issue in `patch_bug`: Identify the specific code lines in patch_bug responsible for the bug. Report the exact affected line and explain why they led to the issue. One single line number for change.
2. The specific changes in `patch_fix` that correct the issue: Explain how the bug was resolved, but keep the focus on mapping fixes back to the faulty lines in `patch_bug`.
Output Format:
Provide a structured response that explicitly maps faulty lines in `patch_bug` to the fix in `patch_fix`, like this:
{{
"root_cause": {{
"filename": "<file_path>",
"line": [<line_number>],
"explanation": "<Why these lines introduced the bug>"
}},
"fix": {{
"filename": "<file_path>",
"line": [<line_number>],
"explanation": "<How these changes in patch_fix resolved the issue>"
}}
}}
Bug commit message: {bug_commit_message}
{patch_bug}
Fix commit message: {fix_commit_message}
{patch_fix}
"""
You are an expert reviewer for source code with extensive experience in analyzing and summarizing code changes.
The bug associated with patch_bug was introduced and later fixed. Below, you can find further information about the fix.
Fix title: {fix_title}
Fix description: {fix_description}
Your task:
Analyze the provided code and generate a concise summary focusing on the exact changes in patch_bug that introduced the issue and how patch_fix resolved it. Ignore any modifications unrelated to the bug fix.
You must report:
1. The root cause of the issue in `patch_bug`: Identify the specific code lines in patch_bug responsible for the bug. Report the exact affected line and explain why they led to the issue. One single line number for change.
2. The specific changes in `patch_fix` that correct the issue: Explain how the bug was resolved, but keep the focus on mapping fixes back to the faulty lines in `patch_bug`.
Output Format:
Provide a structured response that explicitly maps faulty lines in `patch_bug` to the fix in `patch_fix`, like this:
{{
"root_cause": {{
"filename": "<file_path>",
"line": [<line_number>],
"explanation": "<Why these lines introduced the bug>"
}},
"fix": {{
"filename": "<file_path>",
"line": [<line_number>],
"explanation": "<How these changes in patch_fix resolved the issue>"
}}
}}
Bug commit message: {bug_commit_message}
{patch_bug}
Fix commit message: {fix_commit_message}
{patch_fix}
"""

{patch_fix}
"""

FILTERING_COMMENTS = """

@suhaibmujahid suhaibmujahid Jul 9, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{bug_summarization}
"""

CODE_GEN_BUG_FIX = """

@suhaibmujahid suhaibmujahid Jul 9, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subcategories include:
* None of the above
* Does not apply
- Keep It Focused: Limit your comments to the issues that could lead to problems identified by the Jira ticket and are directly related to the changes made in the Patch fixing the bug.

@suhaibmujahid suhaibmujahid Jul 9, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make it generic instead of specifying Jira here.

suhaibmujahid and others added 2 commits July 15, 2025 17:24
Replaces the incorrect use of bugzilla.COMMITS_DB with repository.COMMITS_DB in the documentation example to ensure the correct database is downloaded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@suhaibmujahid suhaibmujahid suhaibmujahid requested changes

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[code_review] Add generated synthetic examples from past bugs for RAG

AltStyle によって変換されたページ (->オリジナル) /