Merge pull request #28849 from hghtwr/master

fix: encode group path for getGroupByPath (#28826)
This commit is contained in:
Ben Lambert
2025-02-18 08:48:24 +01:00
committed by GitHub
3 changed files with 29 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-gitlab': patch
---
Fix `GitlabOrgDiscoveryEntityProvider` group path not being encoded causing 404 when using a subgroup in `config.group`
@@ -139,17 +139,27 @@ const httpHandlers = [
// https://docs.gitlab.com/ee/api/groups.html#list-group-details supports encoded path and id
const httpGroupFindByEncodedPathDynamic = all_groups_response.flatMap(group => [
// Handler for apiBaseUrl
rest.get(`${apiBaseUrl}/groups/${group.full_path}`, (_, res, ctx) => {
return res(
ctx.json(all_groups_response.find(g => g.full_path === group.full_path)),
);
}),
rest.get(
`${apiBaseUrl}/groups/${encodeURIComponent(group.full_path)}`,
(_, res, ctx) => {
return res(
ctx.json(
all_groups_response.find(g => g.full_path === group.full_path),
),
);
},
),
// Handler for apiSaaSBaseUrl
rest.get(`${apiBaseUrlSaas}/groups/${group.full_path}`, (_, res, ctx) => {
return res(
ctx.json(all_groups_response.find(g => g.full_path === group.full_path)),
);
}),
rest.get(
`${apiBaseUrlSaas}/groups/${encodeURIComponent(group.full_path)}`,
(_, res, ctx) => {
return res(
ctx.json(
all_groups_response.find(g => g.full_path === group.full_path),
),
);
},
),
]);
const httpGroupFindByIdDynamic = all_groups_response.map(group => {
@@ -174,7 +174,10 @@ export class GitLabClient {
groupPath: string,
options?: CommonListOptions,
): Promise<GitLabGroup> {
return this.nonPagedRequest(`/groups/${groupPath}`, options);
return this.nonPagedRequest(
`/groups/${encodeURIComponent(groupPath)}`,
options,
);
}
async listDescendantGroups(