Merge pull request #28883 from StateFarmIns/fix-new-branch-scaffolder-gitlab

Fix to correctly check gitbeaker exception response for 404
This commit is contained in:
Ben Lambert
2025-02-18 08:39:50 +01:00
committed by GitHub
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,