Skip to content

t5559: fix auto-decline safety-net to check any non-bot user comment#5576

Closed
marcusquinn wants to merge 1 commit intomainfrom
fix/t5559-draft-response-review
Closed

t5559: fix auto-decline safety-net to check any non-bot user comment#5576
marcusquinn wants to merge 1 commit intomainfrom
fix/t5559-draft-response-review

Conversation

@marcusquinn
Copy link
Owner

Summary

  • Removes the select(.user.login == "${username}") filter from the safety-net comment check in cmd_check_approvals (line 838)
  • The filter was incorrectly restricting the "has a user commented?" check to only the authenticated agent account, making comments from any other human user invisible
  • Now correctly counts any comment from a non-bot user, preventing false auto-declines when a human other than the agent has engaged on the issue

Root cause

The jq filter combined two conditions: match the agent's own username AND exclude bots. The intent (per the surrounding comment "Only auto-decline if no user comment exists") is to check for any non-bot human comment. The username equality filter was logically wrong for this purpose.

Change

- --jq "[.[] | select(.user.login == \"${username}\") | select(.user.login | test(\"\\\\[bot\\\\]\$\"; \"i\") | not)]" \
+ --jq "[.[] | select(.user.login | test(\"\\\\[bot\\\\]\$\"; \"i\") | not)]" \

Verification

  • ShellCheck: no new violations (only pre-existing SC1091 info on external source)
  • 1 file changed, 1 line modified

Closes #5559

The safety-net auto-decline logic (t5520) was filtering comments to only
those from the authenticated agent user (`${username}`), then excluding
bots. This meant a comment from any *other* human user was invisible to
the check, causing incorrect auto-declines when a non-agent user had
already engaged on the issue.

Remove the username equality filter; keep only the bot-exclusion test so
the guard correctly fires when *any* non-bot user has commented.

Fixes #5559 (Gemini review feedback from PR #5522)
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • no-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 648c44aa-2401-4fe7-94fa-6fe6fab260fc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/t5559-draft-response-review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 pull request addresses a bug in the auto-decline safety-net mechanism that was causing issues to be incorrectly auto-declined. The fix involves refining the logic used to detect user comments, ensuring that any human interaction, not just that of the authenticated agent, is recognized. This prevents the system from prematurely closing issues due to a misinterpretation of user engagement.

Highlights

  • Auto-decline safety-net fix: Removed the select(.user.login == "${username}") filter from the jq command within the cmd_check_approvals function. This change ensures that the system correctly identifies any non-bot user comment, preventing false auto-declines on issues.
  • Corrected comment detection logic: The previous logic incorrectly restricted the 'has a user commented?' check to only the authenticated agent's account. The updated logic now correctly counts comments from any non-bot user, aligning with the intent to prevent auto-declines when any human has engaged.
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.

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.

@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 23, 2026
@github-actions
Copy link
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 488 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Mon Mar 23 18:53:47 UTC 2026: Code review monitoring started
Mon Mar 23 18:53:48 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 488

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 488
  • VULNERABILITIES: 0

Generated on: Mon Mar 23 18:53:50 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn
Copy link
Owner Author

Duplicate of PR #5572 — both address issue #5559. PR #5572 was created first. Closing in favour of #5572.

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

This pull request modifies the draft-response-helper.sh script to remove the filtering of comments by a specific username, allowing all non-bot comments to be considered. The review suggests an improvement to the bot detection logic, recommending the use of user.type != "Bot" from the GitHub API for more robust identification of bot accounts, as it is more reliable than relying on a [bot] suffix in the username.

local sa_comments
sa_comments=$(gh api --paginate "repos/${slug}/issues/${sa_issue_number}/comments?per_page=100" \
--jq "[.[] | select(.user.login == \"${username}\") | select(.user.login | test(\"\\\\[bot\\\\]\$\"; \"i\") | not)]" \
--jq "[.[] | select(.user.login | test(\"\\\\[bot\\\\]\$\"; \"i\") | not)]" \

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 removes the filter for the specific agent's username, the bot detection can be made more robust. Instead of relying on the [bot] suffix in the username, you can use the user.type field provided by the GitHub API. This is a more reliable way to identify bot accounts, as not all bots may follow the [bot] naming convention.

Suggested change
--jq "[.[] | select(.user.login | test(\"\\\\[bot\\\\]\$\"; \"i\") | not)]" \
--jq '[.[] | select(.user.type != "Bot")]' \

@alex-solovyev alex-solovyev reopened this Mar 24, 2026
@github-actions
Copy link
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 510 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Tue Mar 24 09:07:43 UTC 2026: Code review monitoring started
Tue Mar 24 09:07:43 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 510

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 510
  • VULNERABILITIES: 0

Generated on: Tue Mar 24 09:07:46 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@alex-solovyev
Copy link
Collaborator

Closing: merge conflicts with main after reopening. The changes need to be rebased or re-implemented in a fresh branch.

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

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quality-debt: .agents/scripts/draft-response-helper.sh — PR #5522 review feedback (high)

2 participants