Generating Synthetic Code Review Comments from Bug Fix Histories#5037
Open
leusonmario wants to merge 3 commits intomozilla:masterfrom
Open
Generating Synthetic Code Review Comments from Bug Fix Histories#5037leusonmario wants to merge 3 commits intomozilla:masterfrom
leusonmario wants to merge 3 commits intomozilla:masterfrom
Conversation
Collaborator
|
CC @olewicki |
Member
|
The diff was difficult to review because it included 84 commits from the upstream. I cleaned up the branch and rebased it. |
suhaibmujahid
requested changes
Jul 9, 2025
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} | ||
| """ |
Member
There was a problem hiding this comment.
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 = """ |
Member
There was a problem hiding this comment.
Here the same as in https://github.com/mozilla/bugbug/pull/5037/files#r2195000738
| {bug_summarization} | ||
| """ | ||
|
|
||
| CODE_GEN_BUG_FIX = """ |
Member
There was a problem hiding this comment.
Here again, as in https://github.com/mozilla/bugbug/pull/5037/files#r2195000738
| 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. |
Member
There was a problem hiding this comment.
We could make it generic instead of specifying Jira here.
Replaces the incorrect use of bugzilla.COMMITS_DB with repository.COMMITS_DB in the documentation example to ensure the correct database is downloaded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).