Skip to content

Conversation

@wislertt
Copy link

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.

@google-cla
Copy link

google-cla bot commented Nov 20, 2025

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.

@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • Duplicate Comment Fix: This pull request addresses an issue where the github-tf-pull-request action was creating duplicate comments on pull requests due to an incorrect matching logic for identifying its own previous comments.
  • Updated Comment Identification Logic: The core change involves updating the string used to find existing bot comments from 'Terraform Initialization' to 'Terraform Plan Validate All', ensuring the bot correctly identifies and updates its comments instead of posting new ones.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines 80 to 82
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')
})

Choose a reason for hiding this comment

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

medium

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:

  1. Add a hidden HTML comment to the output variable (around line 107):

    const output = `
    ...
    </details>
    ${truncated_message}
    <!-- github-tf-pull-request-comment -->
    `;
  2. Update this find logic 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.

@wislertt wislertt changed the title fix: fix github-tf-pull-request find comment fix: correct github-tf-pull-request comment detection Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant