GitLab for Jira Cloud app: Unlink fails on self-managed instances with a relative URL root (path contains the prefix twice)
Summary
On a GitLab Self-Managed instance served under a relative URL root (for example https://gitlab.example.com/gitlab) and connected through the Atlassian Marketplace listing of the GitLab for Jira Cloud app, Unlink on the app configuration page always fails with:
Failed to unlink group. Please try again.
The unlink request goes to a path that contains the relative URL root twice, for example https://gitlab.example.com/gitlab/gitlab/-/jira_connect/subscriptions/1. The browser blocks the request before sending it, so the group stays linked.
Sign-in, listing groups and linking groups work on the same instance. Only unlinking fails.
Steps to reproduce
- Set up a GitLab Self-Managed instance with a relative URL root, for example
external_url 'https://gitlab.example.com/gitlab'. - Set Jira Connect Proxy URL to
https://gitlab.comand install the GitLab for Jira Cloud app from the Atlassian Marketplace. - In Jira, open the app configuration page, select the self-managed option, and enter
https://gitlab.example.com/gitlab. - Sign in to GitLab and link a group. This works.
- Select Unlink for the linked group.
- In the browser developer tools, look at the unlink request on the Network tab.
Example Project
Not reproducible on GitLab.com, because it needs a self-managed instance with a relative URL root that uses GitLab.com as the Jira Connect proxy.
What is the current bug behavior?
- The
DELETErequest goes tohttps://gitlab.example.com/gitlab/gitlab/-/jira_connect/subscriptions/<id>?jwt=.... The relative URL root appears twice. - The browser blocks the request with a Content Security Policy
connect-srcviolation, because the configuration page allows onlyhttps://gitlab.example.com/gitlab/-/jira_connect/,https://gitlab.example.com/gitlab/api/andhttps://gitlab.example.com/gitlab/oauth/token. The request never reaches the instance, and the HAR shows status0. - The app shows the generic error "Failed to unlink group. Please try again." and the group stays linked.
What is the expected correct behavior?
The DELETE request goes to https://gitlab.example.com/gitlab/-/jira_connect/subscriptions/<id>, and the group is unlinked.
Relevant logs and/or screenshots
Sanitized HAR excerpt from an affected instance (hostname replaced, token removed). Three Unlink attempts:
DELETE https://gitlab.example.com/gitlab/gitlab/-/jira_connect/subscriptions/1?jwt=<removed> -> status 0
DELETE https://gitlab.example.com/gitlab/gitlab/-/jira_connect/subscriptions/2?jwt=<removed> -> status 0
DELETE https://gitlab.example.com/gitlab/gitlab/-/jira_connect/subscriptions/3?jwt=<removed> -> status 0The browser reported a CSP violation for each request:
violated-directive: connect-src
blocked-uri: https://gitlab.example.com/gitlab/gitlab/-/jira_connect/subscriptions/2Output of checks
- Reported on GitLab Self-Managed 18.2.8 with the Marketplace installation, served under a relative URL root.
- The code involved is the same in
v18.2.8-ee,v18.11.13-eeand currentmaster, so upgrading does not fix it.
Results of GitLab environment info
Not collected. The cause is in the code paths below and does not depend on the environment, other than the relative URL root.
Results of GitLab application Check
Not collected, for the same reason.
Possible fixes
The unlink path is built on the instance, and the base URL is added again in the frontend:
- The instance returns
unlink_pathfrom a Rails path helper, which includes the relative URL root (for example/gitlab/-/jira_connect/subscriptions/1):app/serializers/jira_connect/subscription_entity.rb#L7-9 - When the configuration page is served by GitLab.com, the frontend sets the axios
baseURLto the stored instance URL, which also ends in/gitlab:sign_in_gitlab_multiversion/index.vue#L38-43andapi.js#L20-22 removeSubscriptionpassesunlink_pathtoaxiosInstance.delete, and axios combines thebaseURLwith the path, so the prefix appears twice:subscriptions_list.vue#L58-72andapi.js#L24-32
Options:
- In the frontend, strip the instance's relative URL root from
unlink_pathbefore the request, or build the unlink URL from the base URL and the subscription ID. - On the instance, return
unlink_pathwithout the relative URL root, or as an absolute URL. Check the effect on manual installations, where the instance serves the configuration page itself and nobaseURLis set.
Related: #618675 describes the reverse case. There, groups_path from the same serializer is missing the relative URL root (app_data_serializer.rb#L15). The paths in this payload handle the relative URL root inconsistently. A fix for either issue should be tested against both installation methods on an instance with a relative URL root, so that one fix does not break the other case.
Workaround: an instance administrator can remove the link in the Rails console with JiraConnectSubscription.find(<id>).destroy!, followed by JiraConnect::JiraCloudAppDeactivationWorker.perform_async(<namespace_id>). These are the same steps that JiraConnectSubscriptions::DestroyService runs.