Skip to content

chore: return early from detect for edited comments#2674

Merged
chmouel merged 2 commits intotektoncd:mainfrom
zakisk:return-early-in-detect-for-edited-event
Apr 13, 2026
Merged

chore: return early from detect for edited comments#2674
chmouel merged 2 commits intotektoncd:mainfrom
zakisk:return-early-in-detect-for-edited-event

Conversation

@zakisk
Copy link
Copy Markdown
Member

@zakisk zakisk commented Apr 10, 2026

when edited comment event is recieved, we used to return in ParsePayload which is quite late because we don't wanna entertain that event for issue_comment and commit_comment so this commit makes it return early in detect func.

📝 Description of the Change

🔗 Linked GitHub Issue

Fixes #

🧪 Testing Strategy

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

🤖 AI Assistance

AI assistance can be used for various tasks, such as code generation,
documentation, or testing.

Please indicate whether you have used AI assistance
for this PR and provide details if applicable.

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

Important

Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.

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: Claude noreply@anthropic.com

✅ 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

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 refactors GitHub event handling by moving the "created" action validation to the detection phase and removing it from the payload processing logic. Feedback indicates that the new early returns in detect.go render subsequent action checks redundant, which should be removed to improve clarity. Furthermore, rather than deleting test cases for unsupported actions, they should be updated to assert the expected failure reasons and maintain test coverage.

Comment thread pkg/provider/github/detect.go Outdated
Comment on lines 83 to 85
if event.GetAction() == "created" &&
event.GetIssue().IsPullRequest() &&
event.GetIssue().GetState() == "open" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The check event.GetAction() == "created" is redundant here because the function already returns early if the action is not "created" on lines 79-81.

		if event.GetIssue().IsPullRequest() &&
			event.GetIssue().GetState() == "open" {

Comment thread pkg/provider/github/detect.go Outdated
return "", fmt.Sprintf("commit_comment: unsupported action \"%s\"", event.GetAction())
}

if event.GetAction() == "created" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The check if event.GetAction() == "created" is redundant because of the early return on lines 108-110. This if block and its corresponding closing brace (on line 123) should be removed, and the inner logic unindented to improve code clarity and maintainability.

isGH: true,
processReq: true,
},
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Several test cases that verified the behavior of non-"created" actions (such as "deleted" or "something") were removed in this PR. Instead of deleting them, these tests should be updated to assert that processReq is now false and that the correct wantReason is returned. This ensures that the new early return logic in the Detect function is properly covered by the test suite and prevents future regressions.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.86%. Comparing base (658e9d4) to head (f831096).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2674   +/-   ##
=======================================
  Coverage   58.86%   58.86%           
=======================================
  Files         206      206           
  Lines       20329    20330    +1     
=======================================
+ Hits        11967    11968    +1     
  Misses       7589     7589           
  Partials      773      773           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

when edited comment event is recieved, we used to
return in ParsePayload which is quite late because
we don't wanna entertain that event for issue_comment
and commit_comment so this commit makes it return
early in detect func.

Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
@zakisk zakisk force-pushed the return-early-in-detect-for-edited-event branch from 9c1a3a1 to f852d66 Compare April 10, 2026 07:28
@chmouel
Copy link
Copy Markdown
Member

chmouel commented Apr 10, 2026

i'll be honest with you i don't understand, what is getting fix here?

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Apr 10, 2026

is it this bug? #2652

@pipelines-as-code
Copy link
Copy Markdown

🤖 AI Analysis - pr-complexity-rating

As a code review triage assistant, I have analyzed the provided context. Please note that since the specific file diff was not provided, this assessment is based on the PR metadata and branch context.

📊 PR Review Complexity

Dimension Score Rationale
Size 1 Appears to be a focused functional change or sync.
Logic complexity 2 Involves a logical flow change ("return early").
Risk 2 Early returns can affect event processing paths.
Cross-cutting 1 Likely contained within the event detection logic.
Test coverage 2 CI passed, but depends on specific unit test updates.

Overall difficulty: Easy

Summary

This PR implements an "early return" pattern within the detection logic for edited events. Reviewers should verify that the early exit condition does not inadvertently skip necessary downstream processing or side effects required for pipeline execution.

Suggested reviewers focus

  • pkg/eventlistener/ (or equivalent detection logic): Verify the logic surrounding the new early return condition to ensure no state is left uninitialized or listeners un-notified.

Generated by Pipelines-as-Code LLM Analysis

@pipelines-as-code
Copy link
Copy Markdown

🤖 AI Analysis - pr-complexity-rating

To provide an accurate assessment, I have analyzed the provided metadata. Note: As the specific file diff was not included in the payload, this assessment is based on the PR title ("return-early-in-detect-for-edited-event") and the nature of the merge commit.

📊 PR Review Complexity

Dimension Score Rationale
Size 1 Likely a targeted refactor or logic tweak.
Logic complexity 2 Conditional logic change for event detection.
Risk 2 Low impact on core system, but affects event handling.
Cross-cutting 1 Likely isolated to the event detection package.
Test coverage 2 Depends on existing unit tests for event payloads.

Overall difficulty: Easy

Summary

This PR implements an early return in the event detection logic for the edited event type. The reviewer should focus on ensuring that the early exit condition does not inadvertently suppress necessary processing or side effects for subsequent event types.

Suggested reviewers focus

  • pkg/eventlistener/detect.go (or equivalent event parsing logic): Verify that the edited event bypasses the correct code paths without breaking the execution flow for other event triggers.

Generated by Pipelines-as-Code LLM Analysis

@zakisk
Copy link
Copy Markdown
Member Author

zakisk commented Apr 10, 2026

is it this bug? #2652

may be implicitly 🙂 . but I didn't see that issue rather when I saw that edited comments are rejected from parse_payload.go I thought ParsePayload func is not the place to filter the event rather its detect.go for every provider which stops events early without making noise. and I think the reason of noise is the same in #2652

@chmouel chmouel merged commit de6de63 into tektoncd:main Apr 13, 2026
13 checks passed
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.

3 participants