Skip to content

feat(gitlab,bitbucket): warn when adding a repo already scoped on another connection - #9047

Open
mfrancisc wants to merge 2 commits into
apache:mainfrom
mfrancisc:upstream/feat-8947-scope-duplicates-gitlab-bitbucket
Open

feat(gitlab,bitbucket): warn when adding a repo already scoped on another connection#9047
mfrancisc wants to merge 2 commits into
apache:mainfrom
mfrancisc:upstream/feat-8947-scope-duplicates-gitlab-bitbucket

Conversation

@mfrancisc

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #9034, which added the duplicate-scope warning for GitHub. This PR
extends the same feature to GitLab and Bitbucket, per the follow-up noted
in that PR's description (originally tracked in #8947).
When the same repository/project is added under more than one connection, DevLake
stores duplicate domain-layer records and metrics get inflated. The Config UI
previously allowed this with no warning for any plugin; #9034 fixed it for GitHub
only. This PR brings GitLab and Bitbucket to parity.
This PR adds:

  • GET /plugins/gitlab/scope-duplicates and GET /plugins/bitbucket/scope-duplicates
    diagnostics (repos already on multiple connections) and a pre-add check
    (connectionId + gitlabIds/bitbucketIds)
  • Generalization of the Config-UI data-scope-remote component and the scope API
    client so the same dismissible, non-blocking warning now renders for GitHub,
    GitLab, and Bitbucket alike, instead of being hardcoded to GitHub

Save is still allowed; users can choose to proceed intentionally, same as before.

Bitbucket-specific note

Unlike GitHub/GitLab (numeric scope IDs), Bitbucket identifies repositories with a
string owner/repo id. The new endpoint and query parsing handle this as a string
rather than assuming a numeric ID, including comma-separated bitbucketIds query
values (e.g. bitbucketIds=owner/repo-a,owner/repo-b).

Testing

  • Added unit tests for both new endpoints' query parsing and row-grouping logic
    (scope_duplicates_api_test.go for each plugin), following the same test
    structure as the existing GitHub tests.
  • Verified locally end-to-end via docker-compose-dev-mysql.yml: confirmed
    GET /plugins/{github,gitlab,bitbucket}/scope-duplicates all return 200 with
    the expected {"duplicates": [...]} shape, and that the Config UI bundle
    includes the generalized gitlabIds/bitbucketIds query-param logic.
  • Manually tried to add the same repo to multiple connections, see :
Screenshot 2026-08-12 at 15 44 48

Follow-ups

  • global GET /api/scope-duplicates aggregator across all plugins

mfrancisc and others added 2 commits August 11, 2026 17:37
…Bitbucket

Add scope-duplicates API endpoints for GitLab and Bitbucket, mirroring the
existing GitHub implementation, and generalize the config-ui data-scope-remote
component and scope API client so the duplicate-connection warning works for
all three plugins.

Co-Authored-By: Cursor Agent <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant