fix: correctly check gitbeaker exception response for 404

Signed-off-by: Cory Steers <cory.steers.gmu9@statefarm.com>
This commit is contained in:
Cory Steers
2025-02-17 13:52:56 -06:00
parent 2c65738af2
commit a7b22eb50c
3 changed files with 10 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
---
Fixed bug in gitlabRepoPush where it was looking in the wrong place in the exception response from gitbeaker when checking if the branch already exists
@@ -335,8 +335,10 @@ describe('createGitLabCommit', () => {
describe('createCommitToBranchThatDoesNotExist', () => {
it('should create a new branch', async () => {
mockGitlabClient.Branches.show.mockRejectedValue({
response: {
statusCode: 404,
cause: {
response: {
status: 404,
},
},
});
const input = {
@@ -156,7 +156,7 @@ export const createGitlabRepoPushAction = (options: {
await api.Branches.show(repoID, branchName);
branchExists = true;
} catch (e: any) {
if (e.response?.statusCode !== 404) {
if (e.cause?.response?.status !== 404) {
throw new InputError(
`Failed to check status of branch '${branchName}'. Please make sure that branch already exists or Backstage has permissions to create one. ${getErrorMessage(
e,