Repository navigation
fix(git): retain authentication guidance for push failures - #32078
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
Pull, fetch, fast-forward and rebase toasts leaked the IPC wrapper around the normalized auth message; Git <2.46 also reports 'could not read Password' for remotes whose URL carries a username. Co-Authored-By: Claude <noreply@anthropic.com>
ELI5
When Git couldn't log in to your remote, Orca hid the real reason. Push, Publish Branch, Force Push and Sync said "Check your connection and try again". Pull said something like
Error invoking remote method 'git:pull': Error: fatal: unable to get password from user. Now every remote action says what actually went wrong:What was broken
credential.interactive=false). Under that setting Git 2.55 printsfatal: unable to get password from user. Older Git (2.43 on Ubuntu 24.04) printsfatal: could not read Password for '<url>': terminal prompts disabledwhen the remote URL includes a username. The shared normalizer recognized neither one.Authentication failed. Check your remote credentials., the toast formatter only keptfatal:/remote:lines, so the toast fell back to generic text. Pull, fetch, fast-forward and rebase printed the raw IPC-wrapped string instead.What changed
src/shared/git-remote-error.ts: two more phrases now map to the canonical auth message (unable to get password from user,could not read Password). The message itself is exported asGIT_AUTHENTICATION_FAILED_MESSAGE.src/renderer/src/lib/source-control-remote-error.ts: when an error contains that canonical message (wrapped or not), the toast becomes<Operation> failed. Authentication failed. Check your remote credentials.Operation is one of Publish Branch, Sync, Force Push, Push, Fetch, Fast-forward, Rebase or Pull. Conflict, submodule, hook, non-fast-forward and local-changes messages still win because they're checked first.No changes to Git prompt policy, RPC shape or IPC.
Verification
Real Git, real production code, before/after. A throwaway vitest started a loopback HTTP server that always returns 401. It ran the real
gitPush/gitPull/gitFetchfromsrc/main/git/remote.ts(with Orca's credential guard env), wrapped the error the way Electron IPC does, and passed it throughresolveRemoteOperationErrorMessage. macOS, Git 2.55.0:a45bd06)gitPusherrorfatal: unable to get password from userAuthentication failed. Check your remote credentials.Publish Branch failed. Check your remote access and try again.Publish Branch failed. Authentication failed. Check your remote credentials.… failed. Check your connection and try again.… failed. Authentication failed. Check your remote credentials.Fetch failed. unable to get password from userFetch failed. Authentication failed. Check your remote credentials.Results were the same for a remote URL with and without
user@.Linux Git wording. Ran the same 401 probe with Orca's exact guard env (
GIT_TERMINAL_PROMPT=0,credential.interactive=false,credential.guiPrompt=false) on two Linux hosts:fatal: unable to get password from user, with and without a username in the URL.fatal: could not read Username …, andfatal: could not read Password …when the URL has a username. The original version of this PR missed thecould not read Passwordcase; it's covered now.Windows Git, real machine. On a Windows box (Git 2.55.0.windows.3 with Git Credential Manager as the helper, plus WSL Ubuntu-24.04 Git 2.43.0), a throwaway vitest ran the real
gitPush/gitFetch/gitPullthrough Orca's runner (which adds the prompt guard env), then fed the IPC-wrapped error intoresolveRemoteOperationErrorMessage. Same probe, before and after:https://gitlab.com/...with no saved login):fatal: Cannot prompt because user interactivity has been disabled./fatal: unable to get password from user.main: Push toastPush failed. Check your connection and try again., Pull toastError invoking remote method 'git:pull': Error: fatal: unable to get password from user.Push/Publish Branch/Sync/Fetch/Pull failed. Authentication failed. Check your remote credentials., with and withoutuser@in the URL.could not read Username ...and, withuser@in the URL,could not read Password .... Both are matched now.git@gitlab.com: Permission denied (publickey).) still shows the last stderr line,and the repository exists., on bothmainand this PR. That's the known SSH gap listed below. A GitHub URL where GCM had a saved login gaverepository ... not found, which is unchanged.pnpm testonsrc/shared/git-remote-error.test.ts,src/renderer/src/lib/source-control-remote-error.test.ts,src/shared/git-clone-failure-message.test.ts,src/main/git/remote.test.ts,src/main/git/fetch-error-classification.test.ts,src/main/github/pr-start-point.test.ts, the editor store slice tests and source-control sync tests: 55 files / 549 tests passed.oxlint,oxfmtandpnpm run check:code-quality:changedpass.Visual proof
The original author clicked Publish Branch in a hidden Electron instance (
ORCA_BACKGROUND_LAUNCH=1, CDP screenshots) against a disposable repo and a loopback HTTP 401 server.Before:
(screenshot removed: contained real product data)
After:
(screenshot removed: contained real product data)
There are no screenshots for the Pull/Fetch/Fast-forward/Rebase labels added in the review commit. They use the same toast and were checked with the real-Git probe above.
Compatibility and risks
fatal: unable to get password from usershowsPush failed. unable to get password from user. Check your remote access and try again.That's readable and no worse than today. An older client talking to a new server is unchanged (generic toast).fatal: Authentication failed for '<url>'lines from older hosts still show the URL through the existingfatal:detail path.Permission denied (publickey)) are out of scope. On every platform they still showand the repository exists.Linked issue
Partial fix for #25341 (reported by @matbrgz). Which host or remote failed, SSH failure classification, and recovery actions are still open. Related context: #7986 (GCM popup suppression, the reason Git runs non-interactively). No contributor code was adopted.