From d7fe7f0a99e2d3d2e0243840a7abece912764d51 Mon Sep 17 00:00:00 2001 From: Cory Steers Date: Mon, 3 Mar 2025 14:27:11 -0600 Subject: [PATCH 1/2] fix: udate if statement in catch block to account for new version of gitbeaker Signed-off-by: Cory Steers fix: udate if statement in catch block to account for new version of gitbeaker --- .../src/actions/gitlab.test.ts | 6 ++++-- .../scaffolder-backend-module-gitlab/src/actions/gitlab.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlab.test.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlab.test.ts index b114788afa..e255652f15 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlab.test.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlab.test.ts @@ -643,8 +643,10 @@ describe('publish:gitlab', () => { it('should show proper error message when token has insufficient permissions or namespace not found', async () => { mockGitlabClient.Namespaces.show.mockRejectedValue({ - response: { - statusCode: 404, + cause: { + response: { + status: 404, + }, }, }); const owner = 'infrastructure/devex'; diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlab.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlab.ts index 5c98464d31..b2641e6656 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlab.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlab.ts @@ -387,7 +387,7 @@ export function createPublishGitlabAction(options: { targetNamespaceId = namespaceResponse.id; } catch (e) { - if (e.response && e.response.statusCode === 404) { + if (e.cause?.response?.status === 404) { throw new InputError( `The namespace ${owner} is not found or the user doesn't have permissions to access it`, ); From a75e18f5d7179a098be67db3bba7187e776d4951 Mon Sep 17 00:00:00 2001 From: Cory Steers Date: Mon, 3 Mar 2025 14:37:34 -0600 Subject: [PATCH 2/2] chore: add changeset Signed-off-by: Cory Steers --- .changeset/nice-dolphins-own.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nice-dolphins-own.md diff --git a/.changeset/nice-dolphins-own.md b/.changeset/nice-dolphins-own.md new file mode 100644 index 0000000000..d7acd3a29a --- /dev/null +++ b/.changeset/nice-dolphins-own.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-gitlab': patch +--- + +Change the if statement in the catch block to match what the new version of Gitbeaker will return