Validate credentials#9765
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an explicit “validate current Git credentials” flow to better detect revoked/invalid OAuth tokens (notably for GitHub where anonymous git access can still succeed on public repos), and wires that validation into the project settings UI and Electron IPC.
Changes:
- Add an optional
validateCredentials()capability to git remote providers and implement it for GitHub and GitLab viaGET /user. - Add a new
/git/validate-credentialsclient loader route + fetcher hook, backed by a newgit.validateGitRepositoryCredentialsIPC endpoint in the main process. - Update the project settings form to call the validation fetcher and use its errors to drive the OAuth re-auth banner / hide author email selection when auth errors are present.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/insomnia/src/ui/components/project/project-settings-form.tsx | Switches from loading repo data to calling the new credential-validation fetcher and uses returned errors in the Git auth banner UI. |
| packages/insomnia/src/sync/git/providers/types.ts | Extends the provider interface with optional validateCredentials(). |
| packages/insomnia/src/sync/git/providers/gitlab.ts | Implements credential validation against GitLab’s GET /user. |
| packages/insomnia/src/sync/git/providers/github.ts | Implements credential validation against GitHub’s GET /user. |
| packages/insomnia/src/routes/git.validate-credentials.tsx | Adds a new route + fetcher hook for validating credentials from the renderer. |
| packages/insomnia/src/main/ipc/electron.ts | Adds a new IPC channel type for credential validation. |
| packages/insomnia/src/main/git-service.ts | Adds the main-process validation implementation and registers the IPC handler; also validates credentials during loadGitRepository init. |
| packages/insomnia/src/entry.preload.ts | Exposes the new validation API on window.main.git. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a48a73b to
1f89db3
Compare
|
@mcturco I have completed the suggested changes 🚀 |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>


Summary
validateCredentialsmethod to the GitHub and GitLab provider implementations that hits the provider'sGET /userREST API endpoint — a lightweight, authoritative check that reliably returns HTTP 401 for revoked tokens or uninstalled GitHub Apps (unlike the git wire protocol, which can succeed anonymously on public repos).validateCredentialsmethod to theGitRemoteProviderinterface, with a fallback tofetchRemoteBranchesfor providers that don't implement it.validateGitRepositoryCredentialsIPC handler ingit-service.tsthat looks up the stored credential for a project/workspace and delegates to the appropriate validation strategy.git.validate-credentialsroute and auseGitValidateCredentialsFetcherhook so the UI can trigger credential validation on demand.loadGitRepository(afterGitVCS.init()) to surface revoked tokens as HTTP 4xx errors, which triggers the existing re-auth banner logic.Test plan