Repository navigation
feat(git): report actionable errors for system git credentials - #10741
Conversation
3c56303 to
9365ab8
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues allow unbounded stderr memory growth, duplicate queued credential warnings, and misleading installation advice when Git fails to start.
3 open issues
What changed in this PR
Adds actionable System Git Credentials errors to Insomnia’s existing native Git sign-in flow, forwarding failure reasons to the UI while preserving authentication cancellation behavior.
Changes:
- Classifies credential failures, captures helper diagnostics, and handles missing repository directories.
- Forwards errors through IPC and displays persistent warnings with host/reason deduplication, while keeping background operations quiet.
- Extends unit tests for failure reporting, process options, and cancellation.
| File | Description |
|---|---|
packages/insomnia/src/ui/renderer-listeners.ts |
Displays reason-specific credential warnings and deduplicates toasts. |
packages/insomnia/src/sync/git/providers/native.ts |
Classifies failures, captures stderr, and emits credential errors. |
packages/insomnia/src/sync/git/providers/__tests__/native.test.ts |
Tests diagnostics, deduplication, cancellation, and background behavior. |
packages/insomnia/src/main/ipc/electron.ts |
Declares the credential-error IPC channel. |
packages/insomnia/src/main/git/git-ipc-handler.ts |
Broadcasts credential errors to renderer windows. |
Review effort: Balanced
ac65d39 to
304b02b
Compare
|
❌ KSAI Review: Failed The review did not complete ( Run report (federated) · 0 paid runs · cost not recoverable from a partial log
|
There was a problem hiding this comment.
🟡 Changes recommended
The credential fallback can use an unrelated checkout’s credential store, and toast deduplication can create duplicate persistent warnings when the original warning is queued but not visible.
1 open issue
3 resolved since last review
Review effort: Balanced
b651c77 to
5d535ab
Compare
Manual test results (Windows 11 + Git Credential Manager)Tested the top of the stack (
Not covered: concurrent-fill dedupe in the UI (unit tests only), push/pull (the test repo has no Insomnia files), macOS/Linux process-group cleanup, and Entra ID (non-personal) Azure accounts. Issue: the toast detail hides the credential helper's own errorWhen a helper fails to provide credentials, the Repro
Actual Why
Impact
Suggestion |
21f0176 to
cff2f5a
Compare
1af1660 to
e511b9b
Compare
When System Git Credentials cannot provide credentials, the git operation still fails with the existing authentication error, so current UI flows keep working, and the reason is now reported to the UI as a warning toast: - git could not be started (not installed / not on PATH) - the credential helper has no credentials for the host, including the last line of the helper's stderr - the server rejected the helper's credentials after a retry Also: - run `git credential` with GIT_TERMINAL_PROMPT=0 so a missing credential fails fast with a clear message instead of trying to prompt on a terminal - capture and log the helper's stderr on failure - cancel instead of retrying the request without credentials when fill fails - report a failure shared by concurrent requests only once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- keep at most one credential error toast per host and reason while it is open, so repeated failures do not stack persistent toasts - run git credential without cwd when the repository directory does not exist, instead of reporting "Git not found" for the resulting ENOENT - word the "no credentials" error neutrally: it is also reported when the user closes the credential manager's sign-in, so it no longer tells users who already have Git Credential Manager to install it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…m git missing Keep only the tail of the credential helper's stderr while it runs instead of buffering all of it. Report "git not found" only for ENOENT; other spawn failures (e.g. EACCES) now get their own message with the error details instead of advice to install git. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
e0e8952 to
93d3710
Compare

Problem
When System Git Credentials can't provide credentials, users only see "The operation was canceled" or a generic authentication error, with no hint of the cause. It could be any of these:
PATHThe logs didn't help either, because
git credentialran withstdio: 'ignore'for stderr and its output was thrown away. Also, with no terminal attached,git credential fillcould try to prompt on a TTY when nothing was stored.What changed
sync/git/providers/native.tsgit credentialstderr is captured (capped at 2000 chars). On a non-zero exit it is logged.git credentialnow runs withGIT_TERMINAL_PROMPT=0. A missing credential fails right away with a clear message (... terminal prompts disabled) instead of trying to prompt.git credentialruns withoutcwd(global/system config) instead of failing withENOENT, which would otherwise be reported as "Git not found".fill()returns a typed outcome (filled/stopped/failed+ reason). If fill fails,onAuthreturns{ cancel: true }right away. It no longer retries the request with empty credentials, which could never succeed.onNativeCredentialErrorlistener API andNativeCredentialError { host, reason, detail? }, with these reasons:git-not-found: spawn failed (e.g.ENOENT)no-credentials: the helper exited non-zero or returned no username/password.detailis the last line of the helper's stderr.rejected: the server rejected the credentials again after the single retry from feat(git): implement git credential approval and rejection callbacks in NativeProvider #10738. This also covers the case where the helper had nothing new to offer after a rejection.main/git/git-ipc-handler.ts,main/ipc/electron.tsGitIpcHandlerforwards errors to all windows on the new main→renderer channelgit.native-credential-error.ui/renderer-listeners.tsqueue.visibleToasts), so repeated failures don't stack persistent toasts.Design decision: still end with cancel instead of throwing a custom error
The git operation still ends with
{ cancel: true }, which isomorphic-git turns into aUserCanceledError. We send the specific reason on a side channel instead of throwing a custom error fromonAuth.The existing UI (clone form, push/pull dropdown, staging modal) maps
UserCanceledError→AuthenticationRequiredErrorto start its re-authenticate flow. A custom error would downgrade all of these to a generic "Failed to fetch from remote".Trade-off: the existing generic auth toast (e.g. "Push failed — Connection has expired. Re-authenticate") still appears next to the new specific toast. Its Re-authenticate link doesn't help with System Git Credentials. A follow-up could merge the two.
Notes
GIT_TERMINAL_PROMPT=0and GCM. Based on GCM's logic, this setting only disables terminal prompts. Browser OAuth and GUI prompts in a desktop session are controlled by a separate setting, so GCM sign-in should still work. This has not been verified manually yet (see test plan).PATH./usr/bin/gitshim can still open the CLT install dialog.Testing
Done:
native.test.ts: stderr detail is surfaced,git-not-foundon spawn error, reports are deduped,rejectedafter the retry,GIT_TERMINAL_PROMPT=0is set in the spawn env, missing repository directory runs withoutcwd, no credential errors for background operations, a synchronous spawn failure cancelscwd, neutral wording, background silence) from a code review of the stacknpm run type-checkandnpm run lintpassManual test plan (not yet tested in the app):
osxkeychain) with no credentials for the host → "Couldn't get git credentials" toast that includes the helper detailPATH→ "Git not found" toastGIT_TERMINAL_PROMPT=0; closing the sign-in window → neutral "Couldn't get git credentials" toastStack created with GitHub Stacks CLI • Give Feedback 💬
🤖 Generated with Claude Code