Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Bug Fixes

- Added handling for "Reference does not exist" error during rebasing to prevent action failures when a reference (branch or commit) no longer exists

## v0.2.0 (2025-08-05)

### Dependencies Updated
Expand Down
27 changes: 27 additions & 0 deletions src/Rebaser/__tests__/rebaser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,33 @@ test('Failing rebase due to head base change completes successfully', async () =
expect(error).toBeNull();
});

test('Failing rebase due to reference not existing completes successfully', async () => {
/* Given */
testGithubRebase.result = Promise.reject('HttpError: Reference does not exist');

let error = null;

/* When */
try {
await rebaser.rebasePullRequests([
{
ownerName: 'owner',
repoName: 'repo',
number: 3,
draft: false,
rebaseable: true,
mergeableState: 'behind',
labels: [],
},
]);
} catch (e) {
error = e;
}

/* Then */
expect(error).toBeNull();
});

test('Failing rebase due unknown failure errors', async () => {
/* Given */
testGithubRebase.result = Promise.reject('Some unknown error');
Expand Down
4 changes: 4 additions & 0 deletions src/Rebaser/rebaser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class Rebaser {
warning(`Rebase aborted because the head branch changed for ${JSON.stringify(pullRequest)}`);
return;
}
if (String(e).includes('Reference does not exist')) {
warning(`Reference does not exist for ${JSON.stringify(pullRequest)}. The branch may have been deleted or modified.`);
return;
}
throw new Error(`Error while rebasing for ${JSON.stringify(pullRequest)}: ${String(e)}`);
}
}
Expand Down
Loading