Uploaded image for project: 'OpenShift Pipelines'
  1. OpenShift Pipelines
  2. SRVKP-8323

Fix: Ignore branch deletion events in Bitbucket Data Center webhook

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • None
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      Story (Required)

      As a Pipelines as Code developer trying to process Bitbucket Data Center webhook events I want to ignore branch deletion events to prevent commit validation failures and noisy logs.

      This story addresses a bug where branch deletion events in Bitbucket Data Center cause commit validation failures and unnecessary log entries in Pipelines as Code. Ignoring these events improves the stability and reduces the noise in the system.

      Background (Required)

      Bitbucket Data Center's `repo:refs_changed` webhook event includes a `toHash` with a zero SHA (`0000000000000000000000000000000000000000`) when a branch is deleted. Pipelines as Code previously attempted to process this as a push event, leading to errors. This issue aims to correct that behavior. This is a bug fix related to pull request #2035.

      Out of scope

      Handling other types of invalid webhook events from Bitbucket Data Center. Adding comprehensive end-to-end testing for this specific fix (though E2E testing in a mirrored PR is underway).

      Approach (Required)

      The `ParsePayload` function will be updated to explicitly check for the zero SHA and `DELETE` event type within the Bitbucket Data Center webhook payload. If both conditions are met, the function will return `(nil, nil)`, effectively ignoring the event. This will involve modifying the existing logic to include a check for the `DELETE` type as suggested in the review comments.

      Dependencies

      None

      Acceptance Criteria (Mandatory)

      • The `ParsePayload` function correctly identifies and ignores branch deletion events from Bitbucket Data Center webhooks.
      • No errors or log messages are produced when processing branch deletion events.
      • Unit tests successfully verify that the updated function correctly handles both standard push events and branch deletion events. The existing unit tests should be updated to cover this new logic.
      • E2E testing (in a mirrored PR) confirms the fix in a real-world scenario.

      INVEST Checklist

      Dependencies identified - Verified
      Blockers noted and expected delivery timelines set - Verified (Minor blocker: Gitlint compatibility initially failed, but resolved)
      Design is implementable - Verified
      Acceptance criteria agreed upon - Verified
      Story estimated - Unsatisfied

      Done Checklist

      • Code is completed, reviewed, documented and checked in - Unsatisfied
      • Unit and integration test automation have been delivered and running cleanly in continuous integration/staging/canary environment - Unsatisfied
      • Continuous Delivery pipeline(s) is able to proceed with new code included - Unsatisfied
      • Customer facing documentation, API docs etc. are produced/updated, reviewed and published - Unsatisfied
      • Acceptance criteria are met - Unsatisfied

      Pull Request: https://github.com/openshift-pipelines/pipelines-as-code/pull/2126

              Unassigned Unassigned
              cboudjna@redhat.com Chmouel Boudjnah
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: