fix: correctly check gitbeaker exception response for 404
Signed-off-by: Cory Steers <cory.steers.gmu9@statefarm.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user