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

  1. Set up a GitLab Self-Managed instance with a relative URL root, for example external_url 'https://gitlab.example.com/gitlab'.
  2. Set Jira Connect Proxy URL to https://gitlab.com and install the GitLab for Jira Cloud app from the Atlassian Marketplace.
  3. In Jira, open the app configuration page, select the self-managed option, and enter https://gitlab.example.com/gitlab.
  4. Sign in to GitLab and link a group. This works.
  5. Select Unlink for the linked group.
  6. 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 DELETE request goes to https://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-src violation, because the configuration page allows only https://gitlab.example.com/gitlab/-/jira_connect/, https://gitlab.example.com/gitlab/api/ and https://gitlab.example.com/gitlab/oauth/token. The request never reaches the instance, and the HAR shows status 0.
  • 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 0

The browser reported a CSP violation for each request:

violated-directive: connect-src
blocked-uri: https://gitlab.example.com/gitlab/gitlab/-/jira_connect/subscriptions/2

Output 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-ee and current master, 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:

  1. The instance returns unlink_path from 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
  2. When the configuration page is served by GitLab.com, the frontend sets the axios baseURL to the stored instance URL, which also ends in /gitlab: sign_in_gitlab_multiversion/index.vue#L38-43 and api.js#L20-22
  3. removeSubscription passes unlink_path to axiosInstance.delete, and axios combines the baseURL with the path, so the prefix appears twice: subscriptions_list.vue#L58-72 and api.js#L24-32

Options:

  • In the frontend, strip the instance's relative URL root from unlink_path before the request, or build the unlink URL from the base URL and the subscription ID.
  • On the instance, return unlink_path without the relative URL root, or as an absolute URL. Check the effect on manual installations, where the instance serves the configuration page itself and no baseURL is 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.

Edited by 🤖 GitLab Bot 🤖