Skip to content

feat: implement issue #538 — Title: pr-review-mention: kill the self-trigger — bot's own mention-ack re-fires the listener#544

Open
don-petry wants to merge 1 commit into
mainfrom
dev-lead/issue-538-20260626-2321
Open

feat: implement issue #538 — Title: pr-review-mention: kill the self-trigger — bot's own mention-ack re-fires the listener#544
don-petry wants to merge 1 commit into
mainfrom
dev-lead/issue-538-20260626-2321

Conversation

@don-petry

Copy link
Copy Markdown
Contributor

Closes #538

Implemented by dev-lead agent. Please review.

…trigger — bot's own mention-ack re-fires the listener
@don-petry don-petry requested a review from a team as a code owner June 26, 2026 23:29
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@don-petry, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 49 minutes and 11 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0db4c46c-b654-436c-8ab9-9de7b187d80f

📥 Commits

Reviewing files that changed from the base of the PR and between 46c1cd8 and 6986a99.

📒 Files selected for processing (4)
  • .github/workflows/pr-review-mention-reusable.yml
  • .github/workflows/pr-review-mention-tests.yml
  • test/workflows/pr-review-mention/helpers/setup.bash
  • test/workflows/pr-review-mention/self-trigger.bats
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-538-20260626-2321

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.

@sonarqubecloud

Copy link
Copy Markdown

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry don-petry enabled auto-merge (squash) June 26, 2026 23:29

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 introduces Bats-based contract tests and helper functions to verify that the reusable workflow for PR review mentions does not self-trigger on its own comments or fire unexpected mention webhooks. The reviewer's feedback focuses on making the tests and helper functions more robust. Specifically, they suggest updating the awk parser in the setup helper to support alternative YAML block-scalar styles and single-line statements, and replacing strict string assertions in the Bats tests with regular expressions to prevent fragility against minor formatting or quoting changes.

Comment on lines +14 to +18
awk '
/^[[:space:]]*if:[[:space:]]*\|/ { grab=1; next }
grab && /^[[:space:]]*steps:[[:space:]]*$/ { exit }
grab { print }
' "$TT_REUSABLE"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current awk parser is tightly coupled to the block-scalar syntax if: |. If the workflow is ever refactored to use a single-line if: statement or a different block-scalar indicator like >, this helper will fail to extract the guard condition.

We can make the parser more robust by:

  1. Supporting both | and > block-scalar indicators.
  2. Supporting single-line if: statements by stripping the if: prefix and printing the condition directly.
  awk '
    /^[[:space:]]*if:[[:space:]]*[|>]/ { grab=1; next }
    /^[[:space:]]*if:[[:space:]]+/ { sub(/^[[:space:]]*if:[[:space:]]*/, ""); print; next }
    grab && /^[[:space:]]*steps:[[:space:]]*$/ { exit }
    grab { print }
  ' "$TT_REUSABLE"

@test "if-guard excludes comments authored by the bot itself" {
run prm_if_guard
[ "$status" -eq 0 ]
[[ "$output" == *"github.event.comment.user.login != 'donpetry-bot'"* ]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The assertion uses strict string matching with single quotes ('donpetry-bot'). If the workflow file is modified to use double quotes (e.g., "donpetry-bot") or if whitespace around != is adjusted, this test will fail.

Using a regular expression match (=~) makes the test much more resilient to minor formatting changes.

  [[ "$output" =~ github\.event\.comment\.user\.login[[:space:]]*!=[[:space:]]*['"]donpetry-bot['"] ]]

@test "if-guard excludes comments carrying a pr-review-agent marker" {
run prm_if_guard
[ "$status" -eq 0 ]
[[ "$output" == *"!contains(github.event.comment.body, '<!-- pr-review-agent')"* ]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the previous test, using strict string matching with single quotes makes the test fragile to quote style changes or whitespace adjustments. Using a regular expression match (=~) is more robust.

  [[ "$output" =~ !contains\(github\.event\.comment\.body,[[:space:]]*['"]<!--[[:space:]]*pr-review-agent['"]\) ]]

@test "if-guard still requires an @donpetry-bot mention to fire (trigger preserved)" {
run prm_if_guard
[ "$status" -eq 0 ]
[[ "$output" == *"contains(github.event.comment.body, '@donpetry-bot')"* ]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a regular expression match (=~) instead of strict string matching prevents the test from breaking if the quote style or whitespace changes in the workflow file.

  [[ "$output" =~ contains\(github\.event\.comment\.body,[[:space:]]*['"]@donpetry-bot['"]\) ]]

@test "if-guard still gates on trusted author_association (trust gate preserved)" {
run prm_if_guard
[ "$status" -eq 0 ]
[[ "$output" == *'["OWNER","MEMBER","COLLABORATOR"]'* ]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The strict string match for the JSON array ["OWNER","MEMBER","COLLABORATOR"] is fragile to formatting changes (such as adding spaces after commas or switching to single quotes). A regular expression match is more resilient.

  [[ "$output" =~ \\[[[:space:]]*['"]OWNER['"][[:space:]]*,[[:space:]]*['"]MEMBER['"][[:space:]]*,[[:space:]]*['"]COLLABORATOR['"][[:space:]]*\\] ]]

@don-petry don-petry disabled auto-merge June 26, 2026 23:31
@don-petry don-petry enabled auto-merge (squash) June 26, 2026 23:41
@don-petry don-petry disabled auto-merge June 26, 2026 23:41
@don-petry don-petry enabled auto-merge (squash) June 26, 2026 23:52
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.

Title: pr-review-mention: kill the self-trigger — bot's own mention-ack re-fires the listener

2 participants