Skip to content

fix: Avoid webhook feedback loop on no-ops comment events#2504

Merged
zakisk merged 5 commits intotektoncd:mainfrom
chmouel:avoid-comment-loop-on-noop
Feb 27, 2026
Merged

fix: Avoid webhook feedback loop on no-ops comment events#2504
zakisk merged 5 commits intotektoncd:mainfrom
chmouel:avoid-comment-loop-on-noop

Conversation

@chmouel
Copy link
Copy Markdown
Member

@chmouel chmouel commented Feb 24, 2026

Added logic to prevent errors from no-ops comment events from creating a feedback loop. When a "no-ops" comment event occurs, the MetadataResolve error is now skipped, preventing the creation of a comment that would re-trigger the same event.

The test case for Gitea was updated to account for this change. It now waits for a short period to allow any potential feedback loops to settle and then asserts that only a single failure comment was posted, rather than multiple duplicates.

For whatever reasons i could not reproduce this behaviour with github webhook and gitlab, only on forgejo

Screenshots

Before

image

After

image

📝 Description of the Change

When a no-ops comment event occurs (e.g., a comment that matches no pipeline configurations), the system was reporting a MetadataResolve error by posting a failure comment. That comment triggered another webhook event, which hit the same error, creating an unbounded feedback loop of duplicate failure comments.

The fix adds a targeted check in pkg/pipelineascode/match.go: if the current event is a no-ops comment event, MetadataResolve errors are silently logged instead of surfaced as failure comments. All other event types retain the existing error-reporting behaviour.

👨🏻‍ Linked Jira

https://issues.redhat.com/browse/SRVKP-10912

🔗 Linked GitHub Issue

Fixes #

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

Added logic to prevent errors from no-ops comment events from creating a
feedback loop. When a "no-ops" comment event occurs, the MetadataResolve
error is now skipped, preventing the creation of a comment that would
re-trigger the same event.

The test case for Gitea was updated to account for this change. It now
waits for a short period to allow any potential feedback loops to settle
and then asserts that only a single failure comment was posted, rather
than multiple duplicates.

Jira: https://issues.redhat.com/browse/SRVKP-10912
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Copilot AI review requested due to automatic review settings February 24, 2026 16:05
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @chmouel, 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 potential webhook feedback loop issue where 'no-ops' comment events, when encountering MetadataResolve errors, could repeatedly trigger new comments, leading to an infinite cycle. The changes introduce a mechanism to identify and gracefully handle these specific error conditions for 'no-ops' events, preventing the generation of redundant failure comments and ensuring system stability. The associated test suite has been enhanced to validate this new behavior.

Highlights

  • Feedback Loop Prevention: Implemented logic to prevent webhook feedback loops that could occur when 'no-ops' comment events trigger MetadataResolve errors, by skipping error reporting for these specific events.
  • Gitea Test Enhancement: Updated the Gitea test case for duplicate PipelineRuns to explicitly wait for a short period and then assert that only a single failure comment is posted, confirming the feedback loop prevention.
Changelog
  • pkg/pipelineascode/match.go
    • Introduced logic to prevent MetadataResolve errors from being reported for no-ops comment events.
  • pkg/pipelineascode/match_test.go
    • Updated test cases for getPipelineRunsFromRepo to include scenarios for no-ops comment events and error handling.
  • pkg/pipelineascode/testdata/same_name_pipelineruns/.tekton/run.yaml
    • Added a test YAML file containing duplicate PipelineRun definitions to simulate an error condition.
  • test/gitea_test.go
    • Modified the Gitea test for duplicate PipelineRuns to verify that only a single failure comment is posted after a delay, preventing feedback loops.
Activity
  • The pull request was created by chmouel to fix a webhook feedback loop issue.
  • The author provided a detailed description outlining the problem and the proposed solution, including an update to the Gitea test case.
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.

@pipelines-as-code
Copy link
Copy Markdown

pipelines-as-code bot commented Feb 24, 2026

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 04ee1c3 fix: Avoid webhook feedback loop on no-ops comment events

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

Copy link
Copy Markdown

@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 correctly addresses a webhook feedback loop for no-ops comment events by skipping error reporting for MetadataResolve failures in this specific case. The added unit tests effectively cover the new logic. The E2E test for Gitea is also updated to verify the fix, though I've provided a couple of suggestions to improve the test's robustness.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a webhook feedback loop that occurs when no-ops (unrecognized) comment events encounter MetadataResolve errors. When an error like "duplicate pipelinerun names" occurs, the system creates an error comment on the PR. However, this comment triggers another webhook, which is classified as a no-ops comment event (since it's not a recognized GitOps command), which hits the same error again, creating an infinite loop of error comments.

Changes:

  • Added logic in match.go to skip error reporting for no-ops comment events to prevent feedback loops
  • Added unit tests to verify the fix handles both regular events (which should error) and no-ops events (which should skip the error)
  • Updated integration test to verify only a single failure comment is posted instead of duplicates

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg/pipelineascode/match.go Added check to skip MetadataResolve error reporting for no-ops comment events to prevent webhook feedback loop
pkg/pipelineascode/match_test.go Added unit tests covering both error case (regular events) and skip case (no-ops events)
pkg/pipelineascode/testdata/same_name_pipelineruns/.tekton/run.yaml New test data file with duplicate PipelineRun names to trigger MetadataResolve errors
test/gitea_test.go Updated integration test to verify only one failure comment is created instead of multiple duplicates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chmouel chmouel force-pushed the avoid-comment-loop-on-noop branch from b77189f to 9f15987 Compare February 26, 2026 07:27
if err != nil && len(pipelineRuns) == 0 {
// Don't report errors for no-ops comment events to avoid a webhook feedback loop:
// reporting creates a comment, which triggers another webhook, which hits the same error.
if p.event.EventType == opscomments.NoOpsCommentEventType.String() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IIUC, NoOpsCommentEventType is also an event where we process on-comment annotation so what if there is any error in metadata then it would just return without creating comment on PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

anyway if its NoOpsCommentEventType comment or not it return at line no 262 below

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i think it's fine?
image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the only error that can come back from metadata is:

	if err := pipelineRunsWithSameName(prs); err != nil {
		return []*tektonv1.PipelineRun{}, err
	}

which is what this patch address

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@zakisk any other concern?

@zakisk
Copy link
Copy Markdown
Member

zakisk commented Feb 27, 2026

/test

@pipelines-as-code pipelines-as-code bot added the bug Something isn't working label Feb 27, 2026
@zakisk zakisk merged commit 435b6e4 into tektoncd:main Feb 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants