fix: Avoid webhook feedback loop on no-ops comment events#2504
fix: Avoid webhook feedback loop on no-ops comment events#2504zakisk merged 5 commits intotektoncd:mainfrom
Conversation
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>
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
🔍 PR Lint Feedback
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.goto 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.
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
b77189f to
9f15987
Compare
| 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() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
anyway if its NoOpsCommentEventType comment or not it return at line no 262 below
There was a problem hiding this comment.
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
|
/test |

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
After
📝 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
fix:)feat:)feat!:,fix!:)docs:)chore:)refactor:)enhance:)deps:)🧪 Testing Strategy
🤖 AI Assistance
If you have used AI assistance, please provide the following details:
Which LLM was used?
Extent of AI Assistance:
Important
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer 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.shto automatically addthese co-author trailers to your commits.
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.