-
Notifications
You must be signed in to change notification settings - Fork 108
fix(bitbucketdatacenter): ignore branch deletion events in ParsePayload #2126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
/ok-to-test |
this will fail because your commit message is not gitlint compatible
please consider installing pre-commit job |
/ok-to-test |
1 similar comment
/ok-to-test |
A mirrored PR has been created for E2E testing: #2130 |
@chmouel E2E tests are running here? |
One of the e2e tests (TestGiteaACLCommentsAllowing/Retest) failed, but from reviewing the logs, it looks unrelated to this patch. |
@zakisk ah that's actually a nice github behaviour side effect, because we have the same SHA from the mirrored PR, github automatically sees it on this PR as well |
so check-runs are posted in both PRs? that's nice though |
for _, change := range e.Changes { | ||
if change.ToHash == "0000000000000000000000000000000000000000" { | ||
return nil, nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for _, change := range e.Changes { | |
if change.ToHash == "0000000000000000000000000000000000000000" { | |
return nil, nil | |
} | |
} | |
for _, change := range e.Changes { | |
if change.ToHash == "0000000000000000000000000000000000000000" && change.Type == "DELETE { | |
return nil, nil | |
} | |
} |
@infernus01 if you see in payload changes have type: DELETE
so it would be good if you add this condition with &&
"changes": [{
"ref": {
"id": "refs/heads/test-26196",
"displayId": "test-26196",
"type": "BRANCH"
},
"fromHash": "abda6907a37c451017acea247ee22d2dc457e1aa",
"toHash": "0000000000000000000000000000000000000000",
"refId": "refs/heads/test-26196",
"type": "DELETE"
}]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that change to make is for you @infernus01 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
When a branch is deleted in Bitbucket Data Center, the repo:refs_changed webhook sends a change with toHash set to all-zeros. Previously, Pipelines as Code treated this like a push event, which caused errors when trying to validate a missing commit. This patch detects and ignores such events early in ParsePayload. Fixes openshift-pipelines#2035
/ok-to-test |
/ok-to-test |
you had a fumpt error which i have pushed to your branch to fix |
Oh I see, but the failing of test persists, with the error: |
Changes
When a branch is deleted in Bitbucket Data Center, the
repo:refs_changed
webhook event contains atoHash
with a zero SHA (0000000000000000000000000000000000000000
). Previously, Pipelines as Code would attempt to process this event as a push, resulting in commit validation failures and noisy logs.This patch updates the
ParsePayload
function to detect and ignore such events early, returning(nil, nil)
when a branch deletion is detected. This ensures branch deletions are not processed like standard push events.Fixes #2035
/kind bug
Submitter Checklist
📝 Ensure your commit message is clear and informative. Refer to the How to write a git commit message guide. Include the commit message in the PR body rather than linking to an external site (e.g., Jira ticket).
♽ Run make test lint before submitting a PR to avoid unnecessary CI processing. Consider installing pre-commit and running pre-commit install in the repository root for an efficient workflow.
✨ We use linters to maintain clean and consistent code. Run make lint before submitting a PR. Some linters offer a --fix mode, executable with make fix-linters (ensure markdownlint and golangci-lint are installed).
📖 Document any user-facing features or changes in behavior.
🧪 While 100% coverage isn't required, we encourage unit tests for code changes where possible.
🎁 If feasible, add an end-to-end test. See README for details.
🔎 Address any CI test flakiness before merging, or provide a valid reason to bypass it (e.g., token rate limitations).
If adding a provider feature, fill in the following details:
(update the provider documentation accordingly)