feat: handle repo rename webhooks for Bitbucket and Bitbucket Server#884
Conversation
Triggers a sync when a repo is renamed, reducing the window where a stale slug could be claimed by another repo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6900986. Configure here.
| PULL_REQUEST_REJECTED = "pullrequest:rejected" | ||
| PULL_REQUEST_FULFILLED = "pullrequest:fulfilled" | ||
| REPO_PUSH = "repo:push" | ||
| REPO_UPDATED = "repo:updated" |
There was a problem hiding this comment.
Bitbucket Cloud repo:updated not in webhook subscription list
High Severity
REPO_UPDATED is added as a constant and a handler is wired up, but it's never added to subscribed_events. More critically, WEBHOOK_EVENTS["bitbucket"] in apps/worker/services/repository.py also omits repo:updated. This means Bitbucket Cloud is never told to deliver repo:updated events, so the new handler will never fire. Bitbucket Server works because repo:modified was already present in both lists before this PR.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6900986. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #884 +/- ##
==========================================
- Coverage 92.26% 91.92% -0.34%
==========================================
Files 1307 1317 +10
Lines 48014 50690 +2676
Branches 1632 1632
==========================================
+ Hits 44298 46595 +2297
- Misses 3407 3786 +379
Partials 309 309
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Co-authored-by: Joe Becher <drazisil-codecov@users.noreply.github.com>


Summary
repo:updated(Bitbucket Cloud) andrepo:modified(Bitbucket Server) webhook eventsTaskService().refresh()on rename, reducing the window where a stale slug could be claimed by another repoSecurity concern addressed (per Michelle's review of #883)
The slug staleness window after a rename could allow a different workspace to register a repo under the old slug. This is mitigated by:
Tests cover both the sync trigger and the UUID-based lookup under a slug collision scenario.
Test plan
test_repo_updated_triggers_sync—repo:updatedcallsTaskService.refreshwith correct argstest_repo_updated_lookup_by_uuid_not_slug— sync is triggered for the correct repo even when another workspace has registered a repo with the old nametest_repo_modified_triggers_sync— same for Bitbucket Serverrepo:modifiedtest_repo_modified_lookup_by_service_id_not_slug— same slug collision test for Bitbucket Server🤖 Generated with Claude Code
Note
Medium Risk
Moderate risk because it changes webhook event handling to trigger repository refreshes, which can impact sync workload and correctness; covered by targeted tests including slug-collision scenarios.
Overview
Adds support for Bitbucket Cloud
repo:updatedand Bitbucket Serverrepo:modifiedwebhook events to triggerTaskService.refresh(sync_repos=True)so repo metadata (e.g., renamed slugs) is updated immediately.Extends test coverage to ensure rename events queue a refresh and that lookups rely on immutable identifiers (UUID/service_id) rather than slug, including a slug-collision (hijack) scenario.
Reviewed by Cursor Bugbot for commit 97c72e1. Bugbot is set up for automated code reviews on this repo. Configure here.