Actionable error messages for git init sidecar sync failures#361
Merged
Conversation
) When origin remote is not configured, surface a typed NoOriginRemoteError with a suggestion to run git remote add origin instead of the generic "An unknown error occurred" message. When the upstream tracking branch is set but origin/HEAD is missing (common after git init + push without fetch), detect the specific case in MergeBase and surface ErrNoOriginHEAD with a suggestion to run git fetch origin && git remote set-head origin -a instead of the unhelpful "Push your branch" suggestion that was already followed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
hanabel1
approved these changes
May 28, 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.
Summary
originremote is not configured,chunk sidecar sync/setupnow surfaces a typedNoOriginRemoteErrorwith the message "Git remote "origin" is required for sidecar sync." and suggestion "Run: git remote add origin <url>", instead of the generic "An unknown error occurred"origin/HEADis missing (common aftergit init+git push -uwithoutgit fetch),MergeBase()now detects the specific case and surfacesErrNoOriginHEADwith the suggestion "Run: git fetch origin && git remote set-head origin -a", instead of repeating the "Push your branch" suggestion that was already followedChanges
internal/gitutil/gitutil.go— addErrNoOriginHEADsentinel;MergeBase()checks whether the upstream is set before returning the generic no-origin-HEAD error, and wrapsErrNoOriginHEADwhen it isinternal/sidecar/errors.go— addNoOriginRemoteErrortype (mirrors existingRemoteBaseErrorpattern)internal/sidecar/sync.go— wrapDetectOrgAndRepofailures asNoOriginRemoteErrorinstead of a plainfmt.Errorfinternal/cmd/sidecar.go— handleNoOriginRemoteErrorandErrNoOriginHEADin bothnewSidecarSyncCmdandsidecarSetupSyncerror pathsNote on PR #339
This PR is complementary to #339 (sync redesign). #339 renames the sync entry point and changes
MergeBase()'s fallback command but does not address error surfacing. If #339 merges first, two small adaptations are needed: applyNoOriginRemoteErrorwrapping to bothDetectOrgAndRepocalls in #339's newBootstrap/Syncfunctions, and move theErrNoOriginHEADcheck onto thegit merge-base HEAD origin/HEADfallback that #339 introduces.Test plan
task test)task lint)🤖 Generated with Claude Code