The error on the GitLab for Jira Cloud app was one sentence: "Failed to unlink group. Please try again." The request never left the browser. The path contained /gitlab twice, and the page's Content Security Policy blocked it as a connect-src violation.
This is the story of gitlab-org/gitlab!273219. The first version put an absolute URL in the serializer. A review moved the fix into the frontend instead, so it ships to self-managed instances on the next GitLab.com deploy. I'll cover the doubled prefix, that change of approach, and the spec row that did not actually test the slash check.
The issue: /gitlab/gitlab/-/jira_connect/...
The issue was gitlab-org/gitlab#641176, opened by Govind Kumar. It shows up on a self-managed instance served under a relative URL root, for example https://gitlab.example.com/gitlab, when the GitLab for Jira Cloud app is installed from the Atlassian Marketplace.
Sign-in, listing groups, and linking all worked. Only Unlink failed, and the group stayed linked.
unlink_path is built with jira_connect_subscription_path, which already includes relative_url_root. When GitLab.com serves the configuration page, the frontend also sets the axios baseURL to the stored instance URL, which includes that same root. Axios then joined them into /gitlab/gitlab/-/jira_connect/subscriptions/:id. The browser refused the request.
Manual installs and GitLab.com, which do not set baseURL, were never on this path. There is a related inconsistency on groups_path in gitlab-org/gitlab#618675; this MR does not change that path.
Version 1: an absolute URL from the serializer
My first commit (82a32416ec) changed the serializer to return jira_connect_subscription_url instead of the relative path, and I kept the JSON key as unlink_path:
expose :unlink_path do |subscription|
jira_connect_subscription_url(subscription)
end
The idea was that axios leaves an absolute URL alone, so it would not prepend baseURL again. A frontend example checked that the delete did not go to /gitlab/gitlab/, and a serializer example checked that a configured relative root appears once in the absolute URL.
That fix only helps after each self-managed instance upgrades. And it has a failure mode of its own: a Marketplace install behind a reverse proxy can see a different public URL than Settings.gitlab.url.
The review: fix it where GitLab.com can ship it
Agnes Slota confirmed the cause, then suggested moving the work into removeSubscription in app/assets/javascripts/jira_connect/subscriptions/api.js:
With the Atlassian Marketplace listing, GitLab.com serves the configuration page and its JavaScript, so this reaches instances on older versions too, on the next GitLab.com deploy. The absolute URL in the serializer only helps after each instance upgrades, and it would break unlink for Marketplace installs behind a reverse proxy.
That is a better place to fix it. The configuration page's JavaScript is what sets baseURL and what fires the delete. If we strip the instance pathname prefix there, only when baseURL is set and the path starts with that root, axios requests /-/jira_connect/subscriptions/:id under the instance URL. Instances that do not set baseURL are unchanged. The serializer stays on the relative path.
The final helper is short:
const withoutInstanceRoot = (path) => {
const { baseURL } = axiosInstance.defaults;
if (!baseURL) return path;
const root = new URL(baseURL).pathname.replace(/\/+$/, '');
return path.startsWith(`${root}/`) ? path.slice(root.length) : path;
};
export const removeSubscription = async (removePath) => {
const jwt = await getJwt();
return axiosInstance.delete(withoutInstanceRoot(removePath), {
params: {
jwt,
},
});
};
The ${root}/ check matters. A root of /git must not strip the first four characters of /gitlab/-/jira_connect/....
The spec row that passed with or without the slash
The frontend examples are a table: a relative URL root, a trailing slash on the base URL, a path that already omits the root, a path that only starts like the root, no relative root, and an absolute URL.
describe.each`
baseURL | unlinkPath | expectedPath
${'https://gitlab.example.com/gitlab'} | ${'/gitlab/-/jira_connect/subscriptions/1'} | ${'/-/jira_connect/subscriptions/1'}
${'https://gitlab.example.com/gitlab/'} | ${'/gitlab/-/jira_connect/subscriptions/1'} | ${'/-/jira_connect/subscriptions/1'}
${'https://gitlab.example.com/gitlab'} | ${'/-/jira_connect/subscriptions/1'} | ${'/-/jira_connect/subscriptions/1'}
${'https://gitlab.example.com/git'} | ${'/gitlab/-/jira_connect/subscriptions/1'} | ${'/gitlab/-/jira_connect/subscriptions/1'}
${null} | ${'/-/jira_connect/subscriptions/1'} | ${'/-/jira_connect/subscriptions/1'}
${'https://gitlab.example.com/gitlab'} | ${'https://gitlab.example.com/gitlab/-/jira_connect/subscriptions/1'} | ${'https://gitlab.example.com/gitlab/-/jira_connect/subscriptions/1'}
`('withoutInstanceRoot ($baseURL, $unlinkPath)', ({ baseURL, unlinkPath, expectedPath }) => {
The /git versus /gitlab row is not the one I had first. Jorge Tomás asked for a backend maintainer look, approved the approach, and then pointed out that my earlier row did not test the / check in withoutInstanceRoot:
The path
/git/-/...does not start with the root/gitlab, so this row passes with the/check and also without it. Can we use the row from the earlier suggestion instead? It sets the base URL to.../gitand the path to/gitlab/-/....
He had checked it by changing path.startsWith(${root}/) to path.startsWith(root) and watching the old row stay green. The row now in the table — base URL .../git, path /gitlab/-/..., expected path unchanged — fails if you drop the slash, because /gitlab would be sliced as if it started with /git. That is the example that belongs in the table.
Miguel Rincon did the frontend maintainer review. He approved the MR as a good immediate solution, and he also made a point of honesty I want to keep:
this MR doesn't quite fix the underlying issue at #641176 but it is a good immediate solution so I am approving.
He changed the description so the issue stays open, and left a comment there. The doubled prefix is still a real inconsistency between a path that already includes relative_url_root and a baseURL that includes it again. This MR stops unlink from failing. It does not make every Jira Connect path follow one rule. That is why #641176 is still open, and why #618675 is still listed as related.
The MR merged on 30 November 2026.
What I took away
1. A relative path plus a baseURL that already contains the same prefix will double it. jira_connect_subscription_path is not wrong on its own. It becomes wrong when the client also starts from the instance URL.
2. Prefer the fix that ships with GitLab.com's JavaScript. The Marketplace listing is served from GitLab.com. A serializer change on the instance only helps after every self-managed upgrade, and it can break installs behind a reverse proxy. The frontend change reaches those instances on the next GitLab.com deploy.
3. When you strip a prefix, require the slash after the prefix. /git is a prefix of /gitlab as strings. It is not the same root. startsWith(${root}/) is the check; startsWith(root) is not.
4. A table row that passes with the assertion removed is not covering that assertion. Jorge's edit of the production check was the fastest way to see it. If both versions of the code make the example green, the example is about a different case than you think.
5. It is fine for the issue to stay open when the MR is a targeted fix. Saying that in the description, and leaving the issue open, is clearer than closing a report the change does not fully resolve.
Links
- Issue: gitlab-org/gitlab#641176
- Related path inconsistency: gitlab-org/gitlab#618675
- Merge request: gitlab-org/gitlab!273219
Thanks to Govind Kumar for the issue, to Agnes Slota for moving the fix into the frontend, to Jorge Tomás for the slash-check example, and to Miguel Rincon for the maintainer review and for keeping #641176 open.
If you've been thinking about contributing to GitLab, the community issues are a great place to start: contributors.gitlab.com.
Top comments (0)