fix: Prevent bot self-trigger infinite loops in all workflows #28

Merged
Latte merged 2 commits from hotfix/prevent-bot-self-trigger into dev 2025-12-29 13:13:26 +00:00
Owner

CRITICAL FIX: Bot was triggering itself causing 10+ duplicate runs

Problem:

  • When bot posts comments containing @codebot (e.g., help responses, PR reviews)
  • Workflows trigger on those bot comments
  • Bot responds again with @codebot mention
  • Infinite loop → 10+ duplicate workflow runs → excessive API costs

Solution:

  • Added github.event.comment.user.login != 'Bartender' to all workflow conditions
  • Prevents bot from reacting to its own comments
  • Bot username 'Bartender' is now hardcoded in workflows

Changes:

  • .gitea/workflows/ai-comment-reply.yml: Added bot username check
  • .gitea/workflows/ai-chat.yml: Added bot username check
  • .gitea/workflows/ai-issue-triage.yml: Added bot username check
  • CLAUDE.md: Documented bot self-trigger prevention and username update instructions
  • README.md: Added Step 3 to bot customization with critical warning

Impact:

  • Eliminates infinite loop scenarios
  • Prevents excessive API costs from duplicate runs
  • Workflows only trigger on human user comments

Note: If bot username changes from 'Bartender', all three workflow files must be updated.

CRITICAL FIX: Bot was triggering itself causing 10+ duplicate runs Problem: - When bot posts comments containing @codebot (e.g., help responses, PR reviews) - Workflows trigger on those bot comments - Bot responds again with @codebot mention - Infinite loop → 10+ duplicate workflow runs → excessive API costs Solution: - Added github.event.comment.user.login != 'Bartender' to all workflow conditions - Prevents bot from reacting to its own comments - Bot username 'Bartender' is now hardcoded in workflows Changes: - .gitea/workflows/ai-comment-reply.yml: Added bot username check - .gitea/workflows/ai-chat.yml: Added bot username check - .gitea/workflows/ai-issue-triage.yml: Added bot username check - CLAUDE.md: Documented bot self-trigger prevention and username update instructions - README.md: Added Step 3 to bot customization with critical warning Impact: - Eliminates infinite loop scenarios - Prevents excessive API costs from duplicate runs - Workflows only trigger on human user comments Note: If bot username changes from 'Bartender', all three workflow files must be updated.
Latte added 1 commit 2025-12-29 13:13:13 +00:00
fix: Prevent bot self-trigger infinite loops in all workflows
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 34s
8afad737ba
CRITICAL FIX: Bot was triggering itself causing 10+ duplicate runs

Problem:
- When bot posts comments containing @codebot (e.g., help responses, PR reviews)
- Workflows trigger on those bot comments
- Bot responds again with @codebot mention
- Infinite loop → 10+ duplicate workflow runs → excessive API costs

Solution:
- Added github.event.comment.user.login != 'Bartender' to all workflow conditions
- Prevents bot from reacting to its own comments
- Bot username 'Bartender' is now hardcoded in workflows

Changes:
- .gitea/workflows/ai-comment-reply.yml: Added bot username check
- .gitea/workflows/ai-chat.yml: Added bot username check
- .gitea/workflows/ai-issue-triage.yml: Added bot username check
- CLAUDE.md: Documented bot self-trigger prevention and username update instructions
- README.md: Added Step 3 to bot customization with critical warning

Impact:
- Eliminates infinite loop scenarios
- Prevents excessive API costs from duplicate runs
- Workflows only trigger on human user comments

Note: If bot username changes from 'Bartender', all three workflow files must be updated.
Latte added 1 commit 2025-12-29 13:13:19 +00:00
Merge branch 'dev' into hotfix/prevent-bot-self-trigger
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 31s
3bde95b42d
Latte merged commit 15b1de695b into dev 2025-12-29 13:13:26 +00:00
Latte deleted branch hotfix/prevent-bot-self-trigger 2025-12-29 13:13:26 +00:00
Owner

📋 Pull Request Summary

This PR introduces a critical safeguard to the AI bot workflows by preventing the bot from triggering itself through its own comments, thereby avoiding infinite loops and duplicate workflow runs. It also updates documentation to reflect these changes and adds new commands to the ai-comment-reply workflow triggers.

Type: 🔀 Mixed

Changes

Added:

  • Self-trigger prevention condition (github.event.comment.user.login != 'Bartender') in all three AI bot workflow files
  • Additional commands (changelog, explain-diff) to ai-comment-reply.yml triggers
  • Documentation sections explaining the bot self-trigger prevention and instructions to update the bot username

📝 Modified:

  • ai-chat.yml: Added condition to ignore bot's own comments
  • ai-comment-reply.yml: Added condition to ignore bot's own comments
  • ai-issue-triage.yml: Added condition to ignore bot's own comments
  • CLAUDE.md: Updated workflow descriptions and added detailed notes on self-trigger prevention
  • README.md: Added critical instructions for updating bot username to prevent infinite loops

Files Affected

  • 📝 .gitea/workflows/ai-chat.yml - Added condition to ignore bot's own comments to prevent infinite workflow loops
  • 📝 .gitea/workflows/ai-comment-reply.yml - Added condition to ignore bot's own comments and expanded command triggers
  • 📝 .gitea/workflows/ai-issue-triage.yml - Added condition to ignore bot's own comments to prevent infinite loops
  • 📝 CLAUDE.md - Updated workflow command list and added detailed documentation on bot self-trigger prevention
  • 📝 README.md - Added critical instructions for updating bot username in workflows to prevent infinite loops

Impact

🟡 Scope: Medium
These changes address a critical stability issue by preventing infinite workflow triggers caused by the bot commenting on its own messages. This improves reliability and reduces unnecessary resource consumption. The documentation updates ensure maintainers understand how to properly configure the bot username to avoid this problem.

## 📋 Pull Request Summary This PR introduces a critical safeguard to the AI bot workflows by preventing the bot from triggering itself through its own comments, thereby avoiding infinite loops and duplicate workflow runs. It also updates documentation to reflect these changes and adds new commands to the ai-comment-reply workflow triggers. **Type:** 🔀 Mixed ## Changes **✅ Added:** - Self-trigger prevention condition (`github.event.comment.user.login != 'Bartender'`) in all three AI bot workflow files - Additional commands (`changelog`, `explain-diff`) to ai-comment-reply.yml triggers - Documentation sections explaining the bot self-trigger prevention and instructions to update the bot username **📝 Modified:** - ai-chat.yml: Added condition to ignore bot's own comments - ai-comment-reply.yml: Added condition to ignore bot's own comments - ai-issue-triage.yml: Added condition to ignore bot's own comments - CLAUDE.md: Updated workflow descriptions and added detailed notes on self-trigger prevention - README.md: Added critical instructions for updating bot username to prevent infinite loops ## Files Affected - 📝 `.gitea/workflows/ai-chat.yml` - Added condition to ignore bot's own comments to prevent infinite workflow loops - 📝 `.gitea/workflows/ai-comment-reply.yml` - Added condition to ignore bot's own comments and expanded command triggers - 📝 `.gitea/workflows/ai-issue-triage.yml` - Added condition to ignore bot's own comments to prevent infinite loops - 📝 `CLAUDE.md` - Updated workflow command list and added detailed documentation on bot self-trigger prevention - 📝 `README.md` - Added critical instructions for updating bot username in workflows to prevent infinite loops ## Impact 🟡 **Scope:** Medium These changes address a critical stability issue by preventing infinite workflow triggers caused by the bot commenting on its own messages. This improves reliability and reduces unnecessary resource consumption. The documentation updates ensure maintainers understand how to properly configure the bot username to avoid this problem.
Bartender reviewed 2025-12-29 13:14:21 +00:00
Bartender left a comment
Owner

AI Code Review - Inline Comments

AI Code Review - Inline Comments
Owner

[HIGH] Security

The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. If the bot username changes, this hardcoded string will cause the safeguard to fail, potentially leading to infinite workflow triggers and resource exhaustion.

Recommendation: Parameterize the bot username using a repository secret or environment variable to avoid hardcoding. Alternatively, add a centralized config or documentation reminder to update all workflow files when changing the bot username.

**[HIGH] Security** The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. If the bot username changes, this hardcoded string will cause the safeguard to fail, potentially leading to infinite workflow triggers and resource exhaustion. **Recommendation:** Parameterize the bot username using a repository secret or environment variable to avoid hardcoding. Alternatively, add a centralized config or documentation reminder to update all workflow files when changing the bot username.
Owner

[HIGH] Security

The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This creates a maintenance risk and potential security issue if the bot username changes and the condition is not updated.

Recommendation: Use a variable or secret for the bot username instead of hardcoding. Ensure documentation clearly states the need to update this value in all workflows when renaming the bot.

**[HIGH] Security** The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This creates a maintenance risk and potential security issue if the bot username changes and the condition is not updated. **Recommendation:** Use a variable or secret for the bot username instead of hardcoding. Ensure documentation clearly states the need to update this value in all workflows when renaming the bot.
Owner

[HIGH] Security

The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This hardcoding risks infinite loop triggers if the bot username changes and the condition is not updated.

Recommendation: Replace the hardcoded username with a variable or secret. Add automated checks or documentation to ensure all workflow files are updated when the bot username changes.

**[HIGH] Security** The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This hardcoding risks infinite loop triggers if the bot username changes and the condition is not updated. **Recommendation:** Replace the hardcoded username with a variable or secret. Add automated checks or documentation to ensure all workflow files are updated when the bot username changes.
Owner

[LOW] Maintainability

The documentation clearly explains the need to update the bot username in all workflow files to prevent infinite loops. However, this manual step is error-prone and could be missed during bot renaming.

Recommendation: Consider centralizing the bot username in a single config file or environment variable referenced by all workflows to reduce duplication and risk of inconsistent updates.

**[LOW] Maintainability** The documentation clearly explains the need to update the bot username in all workflow files to prevent infinite loops. However, this manual step is error-prone and could be missed during bot renaming. **Recommendation:** Consider centralizing the bot username in a single config file or environment variable referenced by all workflows to reduce duplication and risk of inconsistent updates.
Owner

[LOW] Maintainability

The README includes a critical step to update the bot username in all workflow files to prevent infinite loops. This is helpful but relies on manual updates.

Recommendation: Add a note or script to automate or verify that the bot username is consistent across all workflow files to reduce human error.

**[LOW] Maintainability** The README includes a critical step to update the bot username in all workflow files to prevent infinite loops. This is helpful but relies on manual updates. **Recommendation:** Add a note or script to automate or verify that the bot username is consistent across all workflow files to reduce human error.
Owner

AI Code Review

This PR adds critical safeguards to the GitHub/Gitea workflow YAML files to prevent infinite loops caused by the bot triggering itself via its own comments. It also updates documentation to clearly explain this requirement and the need to update the bot username in multiple places if changed. The changes are well-scoped, address a significant operational risk, and improve maintainability and clarity of the workflows.

Summary

Severity Count
HIGH 3
MEDIUM 0
LOW 2

Review Findings

  • [HIGH] .gitea/workflows/ai-chat.yml:18 - The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. If the bot username changes, this hardcoded value will cause the safeguard to fail, potentially leading to infinite workflow triggers.
  • [HIGH] .gitea/workflows/ai-comment-reply.yml:18 - The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This creates a maintenance risk and potential security issue if the bot username changes and the condition is not updated.
  • [HIGH] .gitea/workflows/ai-issue-triage.yml:13 - The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This hardcoding risks failure of the safeguard if the bot username changes and the condition is not updated.
  • [LOW] CLAUDE.md:210 - The documentation clearly explains the need to update the bot username in all workflow files to prevent infinite loops. However, this manual step is error-prone and could be automated or improved.
  • [LOW] README.md:484 - The README adds a critical step to update the bot username in all workflow files to prevent infinite loops. This is a helpful addition but could be enhanced with examples or links to the exact lines/files.

Overall Severity: HIGH
AI Recommendation: Changes Requested

<!-- AI_PR_REVIEW --> ## AI Code Review This PR adds critical safeguards to the GitHub/Gitea workflow YAML files to prevent infinite loops caused by the bot triggering itself via its own comments. It also updates documentation to clearly explain this requirement and the need to update the bot username in multiple places if changed. The changes are well-scoped, address a significant operational risk, and improve maintainability and clarity of the workflows. ### Summary | Severity | Count | |----------|-------| | HIGH | 3 | | MEDIUM | 0 | | LOW | 2 | ### Review Findings - **[HIGH]** `.gitea/workflows/ai-chat.yml:18` - The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. If the bot username changes, this hardcoded value will cause the safeguard to fail, potentially leading to infinite workflow triggers. - **[HIGH]** `.gitea/workflows/ai-comment-reply.yml:18` - The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This creates a maintenance risk and potential security issue if the bot username changes and the condition is not updated. - **[HIGH]** `.gitea/workflows/ai-issue-triage.yml:13` - The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This hardcoding risks failure of the safeguard if the bot username changes and the condition is not updated. - **[LOW]** `CLAUDE.md:210` - The documentation clearly explains the need to update the bot username in all workflow files to prevent infinite loops. However, this manual step is error-prone and could be automated or improved. - **[LOW]** `README.md:484` - The README adds a critical step to update the bot username in all workflow files to prevent infinite loops. This is a helpful addition but could be enhanced with examples or links to the exact lines/files. --- **Overall Severity:** `HIGH` **AI Recommendation:** Changes Requested
Owner

📋 Pull Request Summary

This PR introduces a critical safeguard to the AI bot workflows by preventing the bot from triggering itself via its own comments, thereby avoiding infinite loop executions. It also updates documentation to reflect the new commands supported and provides clear instructions for updating the bot username in workflows to maintain this protection.

Type: 🔀 Mixed

Changes

Added:

  • Self-trigger prevention condition in all AI bot workflow YAML files
  • Additional commands (changelog, explain-diff) to ai-comment-reply.yml documentation
  • Detailed documentation sections in CLAUDE.md and README.md explaining the bot self-trigger prevention and how to update the bot username

📝 Modified:

  • ai-chat.yml: Added condition to ignore comments from the bot user
  • ai-comment-reply.yml: Added condition to ignore comments from the bot user
  • ai-issue-triage.yml: Added condition to ignore comments from the bot user
  • CLAUDE.md: Updated workflow descriptions and added critical notes about self-trigger prevention
  • README.md: Added step to update bot username in workflows to prevent infinite loops

Files Affected

  • 📝 .gitea/workflows/ai-chat.yml - Added condition to ignore bot's own comments to prevent infinite workflow loops
  • 📝 .gitea/workflows/ai-comment-reply.yml - Added condition to ignore bot's own comments to prevent infinite workflow loops
  • 📝 .gitea/workflows/ai-issue-triage.yml - Added condition to ignore bot's own comments to prevent infinite workflow loops
  • 📝 CLAUDE.md - Updated AI workflow documentation with new commands and detailed instructions on bot self-trigger prevention
  • 📝 README.md - Added critical instructions for updating bot username in workflows to prevent infinite loops

Impact

🟡 Scope: Medium
These changes affect all AI bot-related workflows and documentation, preventing infinite workflow executions caused by the bot triggering itself. This improves system stability and reduces unnecessary resource consumption, while clarifying setup steps for maintainers.

## 📋 Pull Request Summary This PR introduces a critical safeguard to the AI bot workflows by preventing the bot from triggering itself via its own comments, thereby avoiding infinite loop executions. It also updates documentation to reflect the new commands supported and provides clear instructions for updating the bot username in workflows to maintain this protection. **Type:** 🔀 Mixed ## Changes **✅ Added:** - Self-trigger prevention condition in all AI bot workflow YAML files - Additional commands (`changelog`, `explain-diff`) to ai-comment-reply.yml documentation - Detailed documentation sections in CLAUDE.md and README.md explaining the bot self-trigger prevention and how to update the bot username **📝 Modified:** - ai-chat.yml: Added condition to ignore comments from the bot user - ai-comment-reply.yml: Added condition to ignore comments from the bot user - ai-issue-triage.yml: Added condition to ignore comments from the bot user - CLAUDE.md: Updated workflow descriptions and added critical notes about self-trigger prevention - README.md: Added step to update bot username in workflows to prevent infinite loops ## Files Affected - 📝 `.gitea/workflows/ai-chat.yml` - Added condition to ignore bot's own comments to prevent infinite workflow loops - 📝 `.gitea/workflows/ai-comment-reply.yml` - Added condition to ignore bot's own comments to prevent infinite workflow loops - 📝 `.gitea/workflows/ai-issue-triage.yml` - Added condition to ignore bot's own comments to prevent infinite workflow loops - 📝 `CLAUDE.md` - Updated AI workflow documentation with new commands and detailed instructions on bot self-trigger prevention - 📝 `README.md` - Added critical instructions for updating bot username in workflows to prevent infinite loops ## Impact 🟡 **Scope:** Medium These changes affect all AI bot-related workflows and documentation, preventing infinite workflow executions caused by the bot triggering itself. This improves system stability and reduces unnecessary resource consumption, while clarifying setup steps for maintainers.
Bartender reviewed 2025-12-29 13:15:00 +00:00
Bartender left a comment
Owner

AI Code Review - Inline Comments

AI Code Review - Inline Comments
Owner

[HIGH] Security

The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. If the bot username changes, this hardcoded value will cause the safeguard to fail, potentially leading to infinite workflow triggers.

Recommendation: Parameterize the bot username using a workflow environment variable or repository secret to avoid hardcoding. Alternatively, document clearly and enforce updating all workflow files when the bot username changes.

**[HIGH] Security** The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. If the bot username changes, this hardcoded value will cause the safeguard to fail, potentially leading to infinite workflow triggers. **Recommendation:** Parameterize the bot username using a workflow environment variable or repository secret to avoid hardcoding. Alternatively, document clearly and enforce updating all workflow files when the bot username changes.
Owner

[HIGH] Security

The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This creates a maintenance risk and potential security issue if the bot username changes and the condition is not updated.

Recommendation: Use a centralized configuration or environment variable for the bot username to avoid hardcoding. Ensure documentation clearly instructs updating all workflow files if the bot username changes.

**[HIGH] Security** The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This creates a maintenance risk and potential security issue if the bot username changes and the condition is not updated. **Recommendation:** Use a centralized configuration or environment variable for the bot username to avoid hardcoding. Ensure documentation clearly instructs updating all workflow files if the bot username changes.
Owner

[HIGH] Security

The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This hardcoding risks failure of the safeguard if the bot username changes and the condition is not updated.

Recommendation: Avoid hardcoding the bot username by using environment variables or repository secrets. Maintain clear documentation and enforce updating all workflow files when the bot username changes.

**[HIGH] Security** The bot username 'Bartender' is hardcoded in the workflow condition to prevent infinite loops. This hardcoding risks failure of the safeguard if the bot username changes and the condition is not updated. **Recommendation:** Avoid hardcoding the bot username by using environment variables or repository secrets. Maintain clear documentation and enforce updating all workflow files when the bot username changes.
Owner

[LOW] Maintainability

The documentation clearly explains the need to update the bot username in all workflow files to prevent infinite loops. However, this manual step is error-prone and could be automated or improved.

Recommendation: Consider adding a centralized configuration or templating mechanism for the bot username to reduce manual updates and risk of errors. Alternatively, add automated tests or CI checks to verify the username consistency across workflow files.

**[LOW] Maintainability** The documentation clearly explains the need to update the bot username in all workflow files to prevent infinite loops. However, this manual step is error-prone and could be automated or improved. **Recommendation:** Consider adding a centralized configuration or templating mechanism for the bot username to reduce manual updates and risk of errors. Alternatively, add automated tests or CI checks to verify the username consistency across workflow files.
Owner

[LOW] Readability

The README adds a critical step to update the bot username in all workflow files to prevent infinite loops. This is a helpful addition but could be enhanced with examples or links to the exact lines/files.

Recommendation: Add direct links or file paths with line numbers to the README instructions to improve developer experience and reduce errors during bot username changes.

**[LOW] Readability** The README adds a critical step to update the bot username in all workflow files to prevent infinite loops. This is a helpful addition but could be enhanced with examples or links to the exact lines/files. **Recommendation:** Add direct links or file paths with line numbers to the README instructions to improve developer experience and reduce errors during bot username changes.
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Hiddenden/openrabbit#28