Skip to content

fix: check all non-bot users in auto-decline safety net, not just owner#5572

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/5559-draft-response-helper-review
Mar 23, 2026
Merged

fix: check all non-bot users in auto-decline safety net, not just owner#5572
marcusquinn merged 1 commit intomainfrom
bugfix/5559-draft-response-helper-review

Conversation

@alex-solovyev
Copy link
Collaborator

Summary

  • Fixes the high-severity Gemini review finding from PR feat: auto-decline draft-responses when agent determines no reply needed #5522: the safety-net auto-decline jq filter in draft-response-helper.sh was restricting the comment search to only $username (the authenticated user), but the feature's goal is to block auto-decline when any non-bot user has commented
  • Removed the select(.user.login == "${username}") filter and kept only the bot-exclusion filter (select(.user.login | test("\\[bot\\]$"; "i") | not)), so comments from any human user prevent auto-decline
  • Without this fix, a comment from a different non-bot user on the notification issue would be missed, leading to incorrect auto-decline of drafts that have active human engagement

Closes #5559

The safety-net auto-decline jq filter was restricting comment search to
only the authenticated user ($username), but the feature's goal is to
block auto-decline when ANY non-bot user has commented. This could lead
to incorrect auto-declines if a different user commented on the
notification issue.

Remove the username filter and keep only the bot-exclusion filter so
that comments from any human user prevent auto-decline.

Closes #5559
@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: e448983c-5fd2-4410-974e-be768acdfba9

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 bugfix/5559-draft-response-helper-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.

@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 23, 2026
@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 high-severity bug in the auto-decline safety net, ensuring that the system accurately detects human interaction on notification issues. By broadening the scope of comment checks, it prevents drafts from being automatically declined when there's active human engagement, thereby improving the reliability of the automated workflow.

Highlights

  • Auto-decline Logic Correction: The draft-response-helper.sh script's jq filter was updated to correctly identify human engagement. Previously, it only checked for comments from the authenticated user ($username), but now it checks for comments from any non-bot user, preventing incorrect auto-decline of drafts.
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
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:52:46 UTC 2026: Code review monitoring started
Mon Mar 23 18:52:46 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:52:49 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@alex-solovyev
Copy link
Collaborator Author

Closing as duplicate — issue #5559 already has PR #5576 open. Flagging the duplicate per pulse protocol.

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 updates the draft-response-helper.sh script to broaden the criteria for detecting human engagement on issues. Previously, only comments from the repository owner were considered to prevent auto-decline; now, any non-bot user's comment will block auto-decline. A suggestion was made to improve efficiency by consolidating jq calls for counting comments and to avoid suppressing stderr for jq commands to aid debugging.

Comment on lines 840 to 845
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)]' \
2>/dev/null) || sa_comments="[]"
local sa_user_comment_count
sa_user_comment_count=$(echo "$sa_comments" | jq 'length' 2>/dev/null) || sa_user_comment_count=0

Choose a reason for hiding this comment

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

medium

For efficiency, you can get the count of non-bot comments directly within the gh api call, avoiding an intermediate variable and a second jq process. Additionally, the 2>/dev/null suppression has been removed from the suggestion, as it's generally best to avoid suppressing stderr on commands that parse configuration files like jq to prevent hiding syntax errors and making debugging difficult.

Suggested change
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)]' \
2>/dev/null) || sa_comments="[]"
local sa_user_comment_count
sa_user_comment_count=$(echo "$sa_comments" | jq 'length' 2>/dev/null) || sa_user_comment_count=0
local sa_user_comment_count
sa_user_comment_count=$(gh api --paginate "repos/${slug}/issues/${sa_issue_number}/comments?per_page=100" \
--jq '([.[] | select(.user.login | test("\\[bot\\]\[bot\]|actions-user|github-actions\\[bot\\]$"; "i") | not)] | length)') || sa_user_comment_count=0
References
  1. Consolidate multiple 'jq' calls into a single pass where possible to improve performance and script efficiency.
  2. Avoid suppressing stderr with 2>/dev/null on commands that parse configuration files (e.g., jq), as it can hide syntax errors and make debugging difficult.

@marcusquinn marcusquinn merged commit 8cc33d9 into main Mar 23, 2026
33 checks passed
@marcusquinn marcusquinn deleted the bugfix/5559-draft-response-helper-review branch March 23, 2026 18:54
@marcusquinn marcusquinn added the review-feedback-scanned Merged PR already scanned for quality feedback label Mar 23, 2026
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 review-feedback-scanned Merged PR already scanned for quality feedback

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