Skip to content

Commit ace9761

Browse files
fix(bulk-import): fix failing repo list table when GitLab token is bad (#1637)
* fix(bulk-import): fix failing repo list table when GitLab token is bad Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com> * fix(bulk-import): handle code review feedback Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com> * fix(bulk-import): add changeset Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com> --------- Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
1 parent fb21cec commit ace9761

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-bulk-import-backend': patch
3+
---
4+
5+
Fix failing repo list table when GitLab token is bad.

workspaces/bulk-import/plugins/bulk-import-backend/src/gitlab/gitlabApiService.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,33 @@ export class GitlabApiService {
317317
{
318318
dataFetcher: async (gitlab: InstanceType<typeof Gitlab<false>>) => {
319319
// find authenticated gitlab owner...
320-
const username = (await gitlab.Users.showCurrentUser()).username;
321-
if (username) {
322-
allAccessibleUsernames.add(username);
320+
try {
321+
const username = (await gitlab.Users.showCurrentUser()).username;
322+
if (username) {
323+
allAccessibleUsernames.add(username);
324+
}
325+
} catch (err) {
326+
logErrorIfNeeded(
327+
this.logger,
328+
'failed to fetch gitlab current user',
329+
err,
330+
);
323331
}
332+
324333
// ... along with orgs accessible from the token auth
334+
try {
335+
const allGroups = await gitlab.Groups.all<false, 'offset'>({
336+
allAvailable: false,
337+
});
338+
allGroups
339+
.map(org => org.path)
340+
?.forEach((orgName: string) =>
341+
allAccessibleTokenOrgs.add(orgName),
342+
);
343+
} catch (err) {
344+
logErrorIfNeeded(this.logger, 'failed to fetch gitlab groups', err);
345+
}
325346

326-
const allGroups = await gitlab.Groups.all<false, 'offset'>({
327-
allAvailable: false,
328-
});
329-
allGroups
330-
.map(org => org.path)
331-
?.forEach((orgName: string) => allAccessibleTokenOrgs.add(orgName));
332347
return {};
333348
},
334349
},

0 commit comments

Comments
 (0)