"Branch does not exist locally" while rebasing#8546
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an issue in the Create PR webview flow where rebasing (detached HEAD) could trigger a misleading “Branch does not exist locally” error by ensuring the default compare branch is only set when a valid branch name is available.
Changes:
- Add a guard in
setDefaultCompareBranchto no-op whencompareBranchorcompareBranch.nameis missing. - Remove non-null assertions around
compareBranch.nameand consistently use the validated branch name.
Comments suppressed due to low confidence (1)
src/github/createPRViewProvider.ts:687
this.changeBranch(...).then(...)is started but not awaited/returned and has no rejection handler. IfchangeBranchthrows (e.g.,getOrigincan throw when there are no GitHub repos), this becomes an unhandled rejection. Preferawaitwithtry/catch, or at least attach a.catch(...)(and/or prefix withvoid) to make the fire-and-forget behavior explicit and safe.
this.changeBranch(compareBranch.name, false).then(async titleAndDescription => {
const params: Partial<CreateParamsNew> = {
defaultTitle: titleAndDescription.title,
defaultDescription: titleAndDescription.description,
compareBranch: compareBranch.name,
defaultCompareBranch: compareBranch.name,
warning: await this.existingPRMessage(),
};
return this._postMessage({
command: 'pr.initialize',
params,
});
});
aeschli
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8487