-
Notifications
You must be signed in to change notification settings - Fork 792
fix: correct github-tf-pull-request comment detection #1449
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
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @wislertt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This change resolves a bug in the GitHub Action that caused it to post redundant comments on pull requests. By refining the string used to identify its own previous messages, the action will now correctly locate and update existing comments, preventing unnecessary clutter and improving the overall user experience within pull requests. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
Thanks for this contribution. Your change correctly fixes the issue of duplicate comments by updating the search string to match the comment's title. This will resolve the bug. I've added one suggestion to make the comment-finding logic more robust and maintainable in the long run by using a hidden identifier instead of relying on visible text. This will prevent similar issues if the comment's title is changed in the future.
| const botComment = comments.find(comment => { | ||
| return comment.user.type === 'Bot' && comment.body.includes('Terraform Initialization') | ||
| return comment.user.type === 'Bot' && comment.body.includes('Terraform Plan Validate All') | ||
| }) |
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.
While this change correctly fixes the bug, finding the comment by its visible title Terraform Plan Validate All is fragile. If this title text is changed in the future, this logic will break and the action will start creating duplicate comments again.
A more robust approach is to embed a unique, hidden identifier in the comment body and search for that instead. This decouples the search logic from the user-facing text.
You could implement this with two changes:
-
Add a hidden HTML comment to the
outputvariable (around line 107):const output = ` ... </details> ${truncated_message} <!-- github-tf-pull-request-comment --> `;
-
Update this
findlogic to search for the hidden identifier:const botComment = comments.find(comment => { return comment.user.type === 'Bot' && comment.body.includes('<!-- github-tf-pull-request-comment -->') })
This will make your action more resilient to future UI text changes.
Hi, I noticed the action was creating duplicate comments because it couldn’t detect the existing bot comment. This update adjusts the matching logic so the workflow can properly find and update the previous comment. Let me know if anything should be adjusted.